Mysql remote connection in linux

Source: Internet
Author: User
Welcome to the Linux community forum, and interact with 2 million technical staff to access the local computer ip address: 192.168.1.100 Remote Computer ip Address: 192.168.1.244 remote computer to open the mysql server: # etcinit. dmysql. serverstart local computer connection remote mysql Server :. mysql-h192.168.1.244-uroot-

Welcome to the Linux community forum and interact with 2 million technical staff> go to the local computer ip address: 192.168.1.100 Remote Computer ip Address: 192.168.1.244 remote computer to open the mysql server: #/etc/init. d/mysql. server start local computer connection remote mysql server :. /mysql-h "192.168.1.244"-u root-

Welcome to the Linux community forum and interact with 2 million technicians>

Ip address of the Local Computer: 192.168.1.100

Remote Computer ip Address: 192.168.1.244

Open mysql server on a remote computer: #/etc/init. d/mysql. server start

Connect the local computer to the remote mysql Server:./mysql-h "192.168.1.244"-u root-p

The following error occurs:

ERROR 1130 (HY000): Host '192. 168.1.100 'is not allowed to connect to this MySQL server


This occurs because the mysql server is only allowed to log on to the database server locally by default for security reasons.

Solution:

1. Run the following command on the remote computer (ip: 192.168.1.244): Enable server:/etc/init. d/mysql. server start.

Login Server: bin/mysql-u root-p

Use server: mysql> use mysql

Create a remote login user and authorize the user:

Mysql> grant all PRIVILEGES on test. * to andy @ '192. 168.1.100 'identified by '20140901 ';

The preceding statement grants all permissions of the test database to the user andy, allows the user andy to remotely log on to the IP address 192.168.1.100, and sets the password of the user andy to 123456.

The following describes all the parameters one by one:

All PRIVILEGES indicates that all permissions are granted to the specified user. Here, you can also replace it with a specific permission, such as select, insert, update, delete, create, and drop, separate specific permissions with commas.

Test. * Indicates the table to which the preceding Permission applies, and test indicates the database. * indicates all the tables. Therefore, we can infer that: authorize "*. * ", authorize all tables of a database to" database name. * ", authorize a table of a database as" database name. table name ".

Andy indicates the user you want to authorize. This user can be an existing user or a non-existing user.

192.168.1.100 indicates the IP address that allows remote connection. If you want to restrict the IP address, set it to "%.

123456 is the user's password.

After the preceding statement is executed, the following statement can take effect immediately.

> Flush privileges;

2. Local Computer (ip: 192.168.1.100 ):

Run the following command:./mysql-h 192.168.1.244-u andy-p 123456

Shown as follows:

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.