Home  >  Article  >  Backend Development  >  How to set mysql to allow external network access_PHP tutorial

How to set mysql to allow external network access_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:09:041046browse

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;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327366.htmlTechArticlemysql root account, I usually use localhost or 127.0.0.1 when connecting, on the company's test server Mysql is also localhost, so I want to access it and cannot access it, and the test is suspended. Solution:...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn