In Linux, mysql implements remote connection and linuxmysql implements

Source: Internet
Author: User

In Linux, mysql implements remote connection and linuxmysql implements

First, it is clear that mysql does not prohibit remote connection, but the MYSQL account does not allow remote connection. I may think that I am a bit/s, but I think it is very important to distinguish this. By default, remote connection is disabled for all accounts. When installing MYSQL, there is a CHECKBOX in setting the ROOT password. If this option is selected, the remote login function of ROOT is enabled, which is not selected by default.

Exploitation:

Select * frommysql. user

All MYSQL users can find that by default, the host field values of these records are all localhost, which indicates which machines can connect to the local MYSQL using this account. Of course, localhost represents the local machine. Therefore, other machines cannot connect by default.

To enable the remote connection of an account, you only need to change the host field corresponding to this account to the IP address.
For example:

Update user set host = '192. 168.230.2 'whereuser = 'ninty ';

After executing this command, run the following command:
Flush privileges;

To refresh the permission configuration information of all database users so that the settings take effect in a timely manner. Or restart MYSQL.

Change the host of the account ninty to 192.168.230.2, so that the machine 192.168.230.2 can be connected to the MYSQL of the local machine through the account ninty. However, other accounts still cannot be used. Change ninty's host to 192.168.230.2, and only 192.168.230.2 can be used to connect to the MYSQL of the local machine through the ninty account. Other machines (including the local machine) cannot be connected.

If you want to set an account to any IP address, you can log on to it and change host to %. If you can only log on to the IP address of 192.168.230, you can change 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, when the MYSQL server prohibits the local machine to use the corresponding account connection, it will be violent this error. In this case, you can change to an account that allows local connections.

 

ERROR 1045 (28000): Access denied for user 'joejoe1991 '@ 'tqsoft-8HK8AISO' (using password: YES)
This error is generally caused by a user name or Password error. In this case, the local connection is allowed. Otherwise, the above error is reported.

 

ERROR 2003 (HY000): Can't connect to MySQL server on '192. 168.230.2 '(192)
This should be because MYSQL cannot be connected to the network. It may be because the IP address or port is incorrect, or the server has not enabled MYSQL or the firewall has blocked the connection.

 

PS: After MySQL is installed in Linux, the user has no password by default. It is best to set the user password before enabling the remote connection.

 

A simple method is:

Run the mysqladmin-u root password "password" command under the shell command to access the mysql database: [root @ gaoke ~] # Mysql-uroot-p → press enter to enter the password for verification.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.