MySQL for remote connection under Linux

Source: Internet
Author: User

The first thing to understand is that MySQL does not prohibit remote connections, but MySQL accounts prohibit remote connections. I may think I'm a little bit of a literal, but I feel it's important to distinguish that. By default, all accounts are blocked from remote connections. When installing MySQL, there is a checkbox to set the root password, and when selected, the remote login function of root is turned on, which is not selected by default.
Use:

            select * frommysql.user

Find out all the MySQL users, you can see that by default, the value of the host field for these records is all localhost, and this host field indicates which machines can use this account to connect to the native MySQL. LocalHost, of course, represents this machine. So, by default, no other machine can connect.
So if you want to open a remote connection to an account, just change the host field of the account to that IP.
Like what:

            update user set host = ‘192.168.230.2‘ whereuser=‘ninty‘;

After executing this command, you will do the following:

          flush privileges;

To refresh the permissions configuration information for all database users so that the settings take effect immediately. or restart MySQL.
Change the host of the Ninty account to 192.168.230.2, so 192.168.230.2 this machine allows you to connect to the native MySQL by ninty this account, but it is still not possible to use another account. Change the host of Ninty to 192.168.230.2, only 192.168.230.2 this machine can be connected to the native MySQL by ninty this account, other machines (including this one) cannot connect.
If you want to set an account to any IP can be logged in, the host changed to% on the line, if only 192.168.230 this network segment IP can log in, then the host changed to: 192.168.230.%
Some common error messages:
ERROR 1130 (00000): Host ' Aaaaa-8hk8aiso ' isn't allowed to connect to this MySQL server
Aaaaa-8hk8aiso should be the machine name of the machine, when the MySQL server is forbidden to use the corresponding account connection, the error will be violent. At this point to allow the local to connect the account can be.

ERROR 1045 (28000): Access denied for user ' joejoe1991 ' @ ' Tqsoft-8hk8aiso ' (using Password:yes)
This error is usually the user name or password error, this should be allowed to connect the machine, otherwise the report should be the above error.

ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.230.2 ' (10061)
This should be a network for reasons not connected to MySQL, may be IP or port is wrong, or the server does not open MySQL or firewall blocking the connection.

Ps:linux after installing MySQL Default user is no password, it is best to set the user password before turning on the remote connection.

An easy way to do this is to:
The shell command executes mysqladmin-u root password "password", which can be accessed by accessing the MySQL database command:

        [[email protected]~]#mysql -uroot -p → 敲回车 输入密码进行验证。    

MySQL for remote connection under Linux

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.