navicat localhost可以连接mysql,但无法用ip连接的MySQL问题
localhost连接成功:
ip连接不成功:
Windows的mysql:
解决办法:
C:\Users\Administrator>net start mysql
C:\Users\Administrator>mysql -uroot -p123
-p后面的123是密码,注意修改。
赋予所有用户远程连接权限:
mysql>grant all privileges on *.* to 'root'@'%' identified by '123';
解释:
*.*:表示 所有数据库.所有表
%:所有ip
by后面为数据库密码,注意按实际修改。
刷新配置:
mysql>flush privileges;
退回cmd命令行:mysql>quit;
重新启动mysql:
C:\Users\Administrator>net stop mysql
C:\Users\Administrator>net start mysql
CentOs lampp mysql:
解决办法:
进入mysql命令行:
[root@Master bin]# /opt/lampp/bin/mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.1.32-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
进入mysql web管理界面,浏览器输入:
ip/phpadmin
修改mysql数据库中User表里面root用户的%字段的密码为123456,
赋予所有用户远程登录权限:
MariaDB [(none)]>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
刷新配置:
MariaDB [(none)]>FLUSH PRIVILEGES;
命令退出mysql:
MariaDB [(none)]>quit;
重启服务:
/opt/lampp/lampp restart
这时候采用navicat等工具就可以远程连接并操作数据库了。