For the root account of mysql, I usually use localhost or 127.0.0.1 when connecting. Mysql on the company’s test server is also localhost, so I cannot access it and the test is suspended.
Solution:
1. Modify the table, log in to the mysql database, switch to the mysql database, and use the sql statement to view "select host, user from user;"
mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user ='root';
mysql>select host, user from user;
mysql> flush privileges;
Note: The last sentence is very important, the purpose is to make the modification effective. If it is not written, remote connection will still not be possible.
2, authorized user, you want to use root password to connect to the mysql server from any host
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin123' WITH GRANT OPTION;
flush privileges;
If you want to allow user root to connect to the mysql server from the host with ip 192.168.1.104
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.104' IDENTIFIED BY 'admin123' WITH GRANT OPTION;
flush privileges;