1. First set MySQL8.0 allow remote link
mysql> use mysql;
1.1 modify access
mysql> select host,user,plugin from user;
Access 1.2 will be modified to "%", representing allow remote access to any host through the root account
mysql> update user set host='%' where user ='root';
1.3 Update permissions
mysql> FLUSH PRIVILEGES;
1.4 non-root users to perform the following statement (after MySQL8.0 need to create a user to perform authorized operations)
mysql> ceare user 'your_username'@'%';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'%'WITH GRANT OPTION;
2 Port 3306 open
to view the remote host port 3306 is open
netstat -ntlp|grep 3306
If no display means no open port 3306
need to do:
sudo ufw enable # 开启防火墙
sudo ufw default deny # 默认关闭所有外部访问
sudo ufw allow 3306 # 打开3306端口
or
sudo ufw allow IP地址 # 指定允许某主机访问所有端口
If you need to turn off or delete the IP port access
sudo ufw delete allow 端口号/IP地址
Then check the firewall settings.
ufw status look to see if there is no open 3306
Finally, mysql default is to allow only local connections. So we need to modify a configuration file. However, the latest version of the mysql directory structure is not the same as before, the latest version allows remote connections placed under /etc/mysql/mysql.conf.d/mysqld.cnf this configuration file, search for bind-address = 127.0.0.1 line , comment it out and then use the command to restart the mysql service mysql restart services on it.
This method is not the best way to solve MySQL8.0 remote link, then have the ability to check out the official documentation