目录
一、控制台执行
mysql -uroot -p
在提示符输入密码后登录成功
二、在Mysql内执行
use mysql;
grant all privileges on *.* to 'root'@'%' identified by 'password';
flush privileges;
其中password为root密码
三、修改配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# By default we only accept connections from localhost
bind-address = 0.0.0.0
bind-address从127.0.0.1改为0.0.0.0