Set MySQL database to allow remote connection in Linux

Source: Internet
Author: User

Set MySQL database to allow remote connection in Linux

If the following error occurs when you use a client tool to connect to a MySQL database in Linux:

Host '192. 168.1.3 'is not allowed to connect to this MySQL server solution:

1. Access the mysql database on a Linux host

[Root @ mail ~] # Mysql-u root-p root

Solution if the prompt "Can't connect to local MySQL server through socket" appears

Modify/etc/my. cnf
[Mysqld]
Datadir =/database/mysql
Socket =/database/mysql. sock
[Client]
Socket =/database/mysql. sock

The reason why you want to modify the client section is that, from time to time, the mysql client program will still be connected to/var/lib/mysql. the socket sock goes above. Even though the database has been started normally, whether www.bkjia.com uses mysql to connect to the database will still report that/var/lib/mysql cannot be found. sock Error
2. Connect to the database and run

(1) Change the table method. Change the "host" entry in the "user" table in the "mysql" database, and rename it "%" from "localhost"

Mysql-u root-pvmwaremysql> use mysql; mysql> update user set host = '%' where user = 'root'; mysql> select host, user from user;


(2). Authorization Law
Grant all on *. * to 'root' @ '10. 1.1.201 'identified by 'root ';

Then, the user with the ip address 10.1.1.201 can remotely connect to the database.

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.