Enable remote connection for mysql in linux

Source: Internet
Author: User

This article describes in detail how to enable remote connection for mysql in linux. If you need it, refer to it.

Connect to mysql and run the following command:

The Code is as follows: Copy code

Mysql-u root-p
Mysql> use mysql;
Mysql> select host from user where user = 'root ';
Mysql> update user set host = '%' where user = 'root ';
Mysql> flush privileges;
Mysql> select 'host' from user where user = 'root ';

Note: Do not miss the semicolon after some commands!

The first sentence is to authorize the User root to log on.

Second sentence: Select mysql database

Third sentence: view the host value of the user table in the mysql database (the host/IP name that can be accessed through connection)

Fourth sentence: Modify the host value (add host/IP address with the wildcard % content), of course, you can also directly add IP addresses

Fifth sentence: refresh the MySQL system permission table

The sixth statement is modified when you re-view the user table ..

Restart the mysql service: service mysqld restart

The above is the operation method in liunx. The following summarizes the windows method.

1. Go to mysql and create a new user, xuys:

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

The Code is as follows: Copy code
Grant select, update, insert, delete on *. * to xuys@192.168.88.234 identified by "xuys1234 ";


View the result and execute:

The Code is as follows: Copy code
Use mysql;
Select host, user, password from user;


You can see that the created xuys user already exists in the user table. The host field indicates the host to log on to. The value can be an IP address or

Host Name,

Changing the value of the host field to % indicates that you can log on to the mysql server as an xuys user on any client machine. We recommend that you

Set to %.
 

The Code is as follows: Copy code
The Code is as follows: Copy code
Update user set host = '%' where user = 'xuys ';

./Mysqladmin-uroot-ppwd reload
./Mysqladmin-uroot-ppwd shutdown
./Mysqld_safe -- user = root &

Remember: Any modification to the authorization table must be reload again, that is, step 1.

If you still cannot connect from the client after the above three steps, perform the following operations to insert a record in the db table of the mysql database:

The Code is as follows: Copy code

Use mysql;
Insert into db

Values ('2017. 168.88.234 ',' % ', 'xuys', 'y ', 'y', 'y ');
Update db set host = '%' where user = 'xuys ';

Repeat steps 2nd and 3 above.

It is more convenient to use the IDE tool. In EMS MySQL, you can add a user with remote access. When adding the user, enter % for the host, and then select the following permission list.

References

Http://www.bKjia. c0m/database/mysql/34989.htm

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.