MySQL realizes remote connection under Linux

First of all, understand that it is not that mysql prohibits remote connections, but the MYSQL account prohibits remote connections. It might seem like I'm being a bit clumsy, but I feel like it's important to be clear. By default, all accounts are disabled from remote connections. When installing MYSQL, there is a CHECKBOX where the ROOT password is set. If selected, the remote login function of ROOT will be enabled. The default is not selected.
    Use:
       select * frommysql.user to
  find out all MYSQL users, you can find that by default, the values ​​of the host field of these records are all localhost, and this host field indicates which machines can use this account to connect to the local MYSQL. localhost of course represents the local machine. So other machines cannot connect by default.
So if you want to open a remote connection for an account, just change the host field corresponding to the account to that IP.
    For example:
       update user set host = '192.168.230.2' whereuser='ninty';
    After executing this command, execute:
       flush privileges;
to refresh the privilege configuration information of all database users and make the settings take effect in time. 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; however, it is still not possible to use other accounts. Change the host of ninty to 192.168.230.2, only the machine 192.168.230.2 can connect to the MYSQL of this machine through the account of ninty, and other machines (including this machine) cannot connect.
   If you want to set an account to be able to log in from any IP, 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 mistakes Information:
ERROR 1130 (00000):Host 'AAAAA-8HK8AISO' is not allowed to connect to this MySQL server
AAAAA-8HK8AISO should be the machine name of this machine. When the MYSQL server prohibits this machine from using the corresponding account to connect, it will Violent this error. At this time, you can change an account that allows this machine to connect.

ERROR 1045(28000): Access denied for user 'joejoe1991'@'TQSOFT-8HK8AISO' (using password:YES)
This error is usually the user name or password is wrong, this time should be allowed to connect the machine, otherwise the report should be The above is wrong.

ERROR 2003 (HY000): Can't connect to MySQL server on'192.168.230.2' (10061)
This should be due to network reasons. It may be that the IP or port is wrong, or the server does not have MYSQL enabled or the firewall is blocking it. connect.

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

An easy way is:
  Execute mysqladmin -u root password "password" under the shell command, you can access the mysql database command: [root@gaoke~]#mysql -uroot -p → Enter the password for verification.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326181809&siteId=291194637