MySQL database enable external access settings guide _ MySQL

Source: Internet
Author: User
Linuxmysql database enable external access settings guide bitsCN. comLinux sets MySQL and allows external machines to access sudo vi/etc/my. cnf
The specific directory depends on the specific situation. if some people are installed in the personal directory, you can find the corresponding directory.
1. configuration file modification
1. # sudo vim/etc/mysql/my. conf
Find bind-address = 127.0.0.1
Comment out this sentence
II. Mysql database modification
1) [root @ etc] # mysql-u root-p
Enter password:
2) grant all privileges on database. * to admin@192.168.1.1 identified by 'password'
Note:
(1) 192.168.1.1 is the IP address of the client connecting to the Mysql database, rather than the IP address of the database server where the Mysql database is located. remember
(2) password is the password of the root user of the Mysql database, which needs to be modified according to the actual situation.

How to access the MySQL database in Linux?
MySQL database was installed in Linux not long ago, but Linux is a virtual machine, and the Real host is Win7, I tried to use MySQL database tools under Windows 7 to access the MySQL database in Linux. However, a problem occurs during the connection process:
Host '192. 168.0.101 'is not allowed to connect to this MySQL server
Then I tried Baidu to solve this problem and found the following solutions.

Method 1: (modify a table)
Go to the mysql database in Linux, open the user table, find the record with the "host" field value as "localhost", and update the value "localhost" to "% ".
The command is as follows:
# Mysql-u root-p
Enter password:
Mysql> use mysql;
Mysql> update user set host = '%' where user = 'root' and host = 'localhost ';
Mysql> select host, user from user;

Method 2: (authorization)
Example 1
If you want myuser to use mypassword to connect to the MySQL database server from any host. Use the following authorization command:
Grant all privileges on *. * TO [email = 'myuser' @ '%'] % 27 myuser % 27 @ % 27% % 27 [/email] identified by 'mypassword' with grant option;
Example 2
If you want to allow myuser to connect to the MySQL database server from a host with IP address 192.168.0.101 and use mypassword as the password. Use the following authorization command:
Grant all privileges on *. * TO [email = 'myuser' @ '192. 168.0.101 '] % 27 myuser % 27 @ % 27192.168.0.101% 27 [/email] identified by 'mypassword' with grant option;
The above two methods are obtained from the Internet. I solved my problem through example 1 in the second method and successfully connected the MySQL database server in Linux. 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.