MYSQL sets remote user connection

Source: Internet
Author: User
Because of the requirements of project development, the database design has to use the remote mode. However, the remote settings of the database are not that simple. The database of this project is MYSQL5.0. At the beginning, I thought that a remote connection can be performed as long as the database server is installed. However, MYSQL is set for user security. By default, the system does not allow remote user connection and can only be performed locally.

Because of the requirements of project development, the database design has to use the remote mode. However, the remote settings of the database are not that simple. The database of this project is MYSQL5.0. At the beginning, I thought that a remote connection can be performed as long as the database server is installed. However, MYSQL is set for user security. By default, the system does not allow remote user connection and can only be performed locally.

Because of the requirements of project development, the database design has to use the remote mode. However, the remote settings of the database are not that simple. The database of this project is MYSQL5.0. At the beginning, I thought that a remote connection can be performed as long as the database server is installed. However, MYSQL is set for user security. The default system setting is that remote user connection is not allowed, only Local Users can be connected.

You only need to set the HOST value of the system administrator user to allow remote access.

Method 1:

Log On with the root user, and then:

Grant all privileges on *. * to create the username @ "%" identified by "password ";

Flush privileges; * refresh the content just now *

Format: grant permission on database name. Table name to user @ login host identified by "User Password ";

@ Followed by the IP address (or host name) % of the client accessing mysql represents any client. If you enter localhost

Local access (this user cannot remotely access the mysql database ).

You can also set the remote access permission for existing users. As follows:

Use mysql;

Update db set host = '%' where user = 'username'; (if the name is host = localhost, this user does not have the remote access permission)

Flush privileges;

Grant all privileges on *. * TO 'myuser' @ '%' identified by 'mypassword' with grant option;

The above method is found on the Internet.

The following is my own setting method, which is a visual operation.

Method 2:

There is a mysql database under the connection, which is the system database. A user data table stores user information that can be operated on the database.

Open the table, as shown in. As long as we change the host value before the user name to "%", we can allow users to access the database from any IP address.

The principle is the same, but it will be simpler. If the connection still fails, restart the mysql service.

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.