Enable the MYSQL account remote login function _ MySQL

Source: Internet
Author: User
Enable the MYSQL account remote login function bitsCN.com

Xiaoz

For personal study notes, please point out if you have any mistakes. thank you.

I haven't taken any notes for a long time. I'm depressed, and my learning status is not as good as before.
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

View source
Print?
1 select * from mysql. user

All MYSQL users can find that the host field values of these records are all localhost by default.
This host field indicates which machines can use this account to connect to MYSQL on the local machine.
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:

View source
Print?
1 update user set host = 192.168.230.2 where user = ninty;

After executing this command, run the following command:

View source
Print?
1 flush privileges;

To refresh the permission configurations of all database users, so that the settings take effect immediately.
Or restart MYSQL.

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

If you want to set an account to any IP address, you can log on, and change host to %.
If you can only log on to the IP address of 192.168.230, change host:
192.168.230.%

The following are 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): Cant connect to MySQL server on 192.168.230.2 (10061)
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.

BitsCN.com

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.