这是转载StackOverFlow上的回答,原回答点此这里
Remote Access in MySQL 8:
- Allow access from any host
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0
- Allow the user to access from anywhere:
mysql:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
UPDATE mysql.user SET host='%' WHERE user='root';
- Change authentication to password
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'ThePassword';