一、先检查MySQL的登录用户是否开启了访问权限
mysql> use mysql;
mysql> select host,user from user;
mysql-root-state
修改root用户的访问权限
mysql> update user set host = '%' where user = 'root';
为root用户赋予远程访问权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your password' WITH GRANT OPTION;
刷新权限或重启MySQL
mysql> flush privileges;
二、检查MySQL的配置文件是否设置了端口绑定
root@ubuntu: vim /etc/mysql/my.cnf
将文件中的bind-address = 127.0.0.1
注释掉,如下:
# bind-address = 127.0.0.1
保存退出重启MySQL
root@ubuntu: service mysql restart
网友评论