文件路径:
/etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1修改为bind-address = 0.0.0.0
重新启动并登陆mysql
sudo service mysql restart
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