Summary of methods for remote access to the MySQL database

  • 2020-05-09 19:25:39
  • OfStack

Three solutions:
1, change the table method. It may be that your account is not allowed to log in remotely, only on localhost. At this point, once you have logged into mysql from the localhost computer, change the "host" entry in the "user" form of the "mysql" database from "localhost" to "%".
mysql - u root - pvmware
mysql > use mysql;
mysql > update user set host = '%' where user = 'root';
mysql > select host, user from user;
2. Authorization method. For example, if you want myuser to connect to the mysql server from any host using mypassword.
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED 'BY 'mypassword' WITH GRANT OPTION;
If you want to allow the user myuser to connect to the mysql server from the ip 192.168.1.6 host and use mypassword as the password
* GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
The first method I used, I found at the beginning that I couldn't do it, so I checked 1 time on the Internet and executed 1 statement mysql less > FLUSH RIVILEGES
Just put the changes into effect
The third method:
Run on the machine on which mysql is installed:
1, d: \ mysql \ bin \ > mysql -h localhost -u root
// this should allow access to the MySQL server
2, mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION
// grant any host access to the data
3, mysql > FLUSH PRIVILEGES
// the amendment is effective
4, mysql > EXIT
// quit the MySQL server
This allows you to log in as root on any other host.

Related articles: