Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Remote connection realized by mysql under Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

First of all, understand that it is not that mysql prohibits remote connections, but that MYSQL accounts prohibit remote connections. I may think I'm a little literal, but I think it's important to distinguish this point. By default, remote connections are prohibited for all accounts. When installing MYSQL, there is a CHECKBOX in setting the ROOT password. If selected, the remote login function of ROOT is enabled. By default, it is not selected.

Take advantage of:

Select * frommysql.user

If you find out all the MYSQL users, you can find that by default, the value of the host field of these records is all localhost, and this host field indicates which machines can use this account to connect to the local MYSQL. Localhost, of course, represents the native machine. So by default, other machines cannot be connected.

So to open a remote connection to an account, just change the host field corresponding to that account to that IP.

For example:

Update user set host = '192.168.230.2' whereuser='ninty'

After this command is executed, it will be executed:

Flush privileges

To refresh the permission configuration information for all database users to make the settings take effect in a timely manner. Or restart MYSQL.

Change the host of the ninty account to 192.168.230.2, so that the 192.168.230.2 machine is allowed to connect to the local MYSQL; through the ninty account, but it is still not possible to use other accounts. If you change the host of ninty to 192.168.230.2, only 192.168.230.2 can connect to the MYSQL of the local machine through the ninty account, and no other machines (including this machine) can connect.

If you want to set an account so that any IP can log in, just change the host to%; if only the IP of the network segment 192.168.230 can log in, then change the host to: 192.168.230.%

Some common error messages:

ERROR 1130 (00000): Host 'AAAAA-8HK8AISO' is not allowed to connect to this MySQL server

AAAAA-8HK8AISO should be the machine name of the local machine. This error occurs when the MYSQL server forbids the local machine to connect with the corresponding account. At this time, you can change to an account that allows your computer to connect.

ERROR 1045 (28000): Access denied for user 'joejoe1991'@'TQSOFT-8HK8AISO' (using password:YES)

This error is usually an error in the user name or password, which should be allowed to connect to the local computer, otherwise it should be reported as the error above.

ERROR 2003 (HY000): Can't connect to MySQL server on'192.168.230.2' (10061)

This should be due to the lack of connection to MYSQL on the network, maybe the IP or the port is wrong, or the server does not open MYSQL or the firewall blocks the connection.

After installing MySQL under PS:Linux, the default user does not have a password. It is best to set the user's password before opening the remote connection.

A simple way is to:

Execute the mysqladmin-u root password "password" under the shell command by accessing the mysql database command:

[root@gaoke~] # mysql-uroot-p → enter the password to verify.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report