Get the App
SLTechnology News&Howtos  ›  Database  › 

Workaround when remote cannot connect to mysql and there is an error

Shulou Source: shulou.com Published: 2022-05-31 18:00:13 09月28日 Update

The main content of this article is to explain "the solution to which you can't connect to mysql remotely and there is an error". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "remote can not connect to mysql and there is an error solution" bar!

Authorization law.

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

FLUSH PRIVILEGES

If you want to allow the user myuser to connect to the mysql server from the host with ip 192.168.1.6, and use mypassword as the password

GRANT ALL PRIVILEGES ON *. * TO 'myuser'@'192.168.1.3' IDENTIFIED BY' mypassword' WITH GRANT OPTION

FLUSH PRIVILEGES

If you want to allow the user myuser to connect to the dk of the mysql server from the host with an ip of 192.168.1.6, and use mypassword as the password

GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY' mypassword' WITH GRANT OPTION

FLUSH PRIVILEGES

The first method I used, at first, I found that it didn't work. I looked it up on the Internet and executed one less statement > FLUSH RIVILEGES to make the change effective. That's it.

Another method, but I haven't tried it myself. I can find it on csdn.net.

Run on the machine where 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 the right to access data

3. Mysql > FLUSH PRIVILEGES / / the modification takes effect

4. Mysql > EXIT / / exit the MySQL server

This allows you to log in as root on any other host!

At this point, I believe that you can not connect to the mysql remotely and have a deeper understanding of the wrong solution. You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Methods hosts servers services errors content passwords users learning no practical deeper interest practicality practical simple operation data more friends machines Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn Shulou Tech Info macOS MySQL