文件路径:
/etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1修改为bind-address = 0.0.0.0
重新启动并登陆mysql
sudo service mysql restart;
1.在Linux端登录mysql数据库:mysql -uuname -ppassword (默认root用户不能远程登陆)
mysql> use mysql;
查询host值:
mysql> select user,host from user;
2. mysql -uroot -p
修改权限:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
刷新生效
FLUSH PRIVILEGES;
重新启动mysql
sudo service mysql restart;
注意:有时重启服务器后mysql未启动导致远程无法连接只需启动mysql
sudo service mysql start;