How do I set up mysql to allow external network access
- 2020-06-03 06:11:58
For mysql's root account, I usually use localhost or 127.0.0.1 when Connecting. mysql on the company's test server is also localhost, so I want to access it but cannot access it. The test is suspended.
1. Modify the table, log in mysql database, switch to mysql database, use sql statement to view "select host,user from user ";
mysql -u root -pvmwaremysql
mysql > update user set host = '%' where user ='root';
mysql > select host, user from user;
mysql > flush privileges;
Note: The last sentence is important to make the change take effect. If it is not written, the remote connection cannot be made.
2. Authorized user, you want root to use password to connect to mysql server from any host
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin123' WITH GRANT OPTION;
If you want to allow user root to connect to the mysql server from ip's 192.168.1.104 host
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.104' IDENTIFIED BY 'admin123' WITH GRANT OPTION;