How to enable remote logon in mysql

Source: Internet
Author: User
The following describes two methods to enable remote logon for quick mysql. For details, refer to the following.

The following describes two methods to enable remote logon for quick mysql. For details, refer to the following.

The Code is as follows:

Mysql-u root-p
Mysql> use mysql;
Mysql> grant all privileges on *. * to root @ '%' identified by "root ";
Mysql> select host, user, password from user;

+ ----- + -- + --------------- +
| Host | user | password |
+ ----- + -- + --------------- +
| Localhost | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| % | Root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+ ----- + -- + --------------- +
3 rows in set (0.00 sec)

Mysql> flush privileges;

Authorization law:

For example, if you want myuser to use mypassword to connect to the mysql server from any host.

The Code is as follows:

Mysql> grant all privileges on *. * to identified by 'mypassword' with grant option;

If you want to allow myuser to connect to the mysql server from a host whose ip address is 192.168.1.6, and use mypassword as the password

The Code is as follows:

Mysql> grant all privileges on *. * TO 'myuser' @ '192. 168.1.3 'identified by 'mypassword' with grant option;


Note:
1. Format: grant permission on database name. Table name to user @ login host identified by "User Password ";
2. Add ROOT instead of modification. If you change localhost to %, you cannot connect to mysql through localhost;
3. Refresh the MySQL system permission table flush privileges;

For more information about enabling mysql remote connection, see: http://www.111cn.net/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.