Remote access to MySQL database in Ubuntu _ MySQL

Source: Internet
Author: User
Remote access to MySQL database in Ubuntu

BitsCN.com

MySQL remote access command

Format: mysql-h host address-u user name-p user password

Example:

Yanggang @ host :~ $ Mysql-h192.168.1.11-uroot-p123456

ERROR 2003 (HY000): Can't connect to MySQL server on '192. 168.1.11 '(192)

An error occurred! Unable to connect to the remote MySQL database

MySQL can connect to the database remotely in two ways:

Mysql. sock and TCP/IP, the former is faster than the latter, but only limited to the same local machine, see

The preceding error is caused by no remote access permission.

Solution:

1. on the target server (192.168.1.11), modify the mysql my. cnf file:

Sudo vi/etc/mysql/my. cnf

2. comment out bind-address to shield it from listening only to the local device.

# Bind-address = 127.0.0.1

3. start the MySQL service and make the modified configuration take effect. for details, see

Sudo restart mysql

After configuring the data access permissions on the server, you still cannot remotely access the MySQL database.

This is because you have not yet granted access permissions to the database or table on the server (GRANT)

4. log on to the MySQL database on the server

Mysql-u root-p123456

5. grant permissions to the database top800

Grant all privileges on top800. * to root@192.168.1.22 identified by '20140901 ';

Flush privileges;

6 Now you can remotely access MySQL on the server

Mysql-h192.168.1.11-uroot-p123456

By default, only information_schema and top800 can be accessed. top800 is the database that we grant permissions to in step 5.

Knowledge Development:

1. delete the user's access permissions to the database on the server:

Revoke all privileges on top800. * from root@192.168.1.22 identified by '20140901 ';

2. delete the user root on the server:

Delete from user where user = 'hangzhou ';

3. the modification takes effect:

Flush privileges;

4. query users on the server:

From Sunboy_2050

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.