MySQL remote connection setting_mysql

Source: Internet
Author: User
MySQL remote connection settings

This is just a simple Mysql setting. However, many images are simple, but security is ignored. Therefore, you must be clear about the details and meanings of the settings.

The steps are as follows:

1. log on to the local mysql Server:

#mysql -uroot -p

Enter the password and enter mysql. The parameter-u is the user name, here is the root login,-p is to enter the password.

2. use and view mysql User access permissions

>use mysql;>select host,user from user;

3. you can see that the root user can access it locally (using the default mysql installation method ). To run remote access, add the following permissions:

>GRANT ALL PRIVILEGES ON *.* TO ‘myuser’@'%’ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

Here are some notes: all privileges refers to ALL database operations; *. * refers to ALL databases and data tables in the mysql database; % refers to access by running ALL external IP addresses. Myuser and mypassword are the usernames and passwords of the users you want to authorize.

All permissions for the user's database are given here. But in practical applications, the administrator is not responsible.

>GRANT ALL PRIVILEGES ON *.* TO ‘root’@’192.168.1.3′ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

The following is a good practice:

>GRANT ALL PRIVILEGES ON *.* TO ‘root’@’192.168.1.2′ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;>GRANT ALL PRIVILEGES ON mydb.* TO ‘other’@’192.168.1.2′ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

Article 1 The root user can access the database from the machine 192.168.1.2 on the intranet.

Article 2 other is provided to access all tables of mydb data in this database from machines 192.168.1.2 on the intranet.

4. to make the preceding settings take effect immediately, run the following command:

>FLUSH PRIVILEGES;

This allows the mysql Server to load the authorization table again.

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.