Linux MySQL database open external access settings guide _mysql
Source: Internet
Author: User
Linux set MySQL and allow external machines to access sudo vi/etc/my.cnf
The specific directory is specific circumstances, some people are installed in the personal directory, then find the corresponding directory can be.
I. Modification of the configuration file 1. #sudo vim/etc/mysql/my.conf
Find bind-address = 127.0.0.1
Comment out this sentence
second, the MySQL database modification 1) [Root@etc etc]# mysql-u root-p
Enter Password:
2) Grant all privileges on database.* to admin@192.168.1.1 identified by ' password '
Attention:
(1) 192.168.1.1 is the IP address of the client who wants to connect to this MySQL database, not the IP address of the database server where the MySQL database resides, remember
(2) password is the MySQL database root user password, according to the actual situation needs to modify
How do I access a MySQL database in a Linux system? Recently installed in the Linux system MySQL database, but the Linux system is a virtual machine, and the real host is Win7, I tried to Win7 under the MySQL Database Tools to access the MySQL database under the Linux system. However, there is a problem during the connection process:
Host ' 192.168.0.101 ' isn't allowed to connect to this MySQL server
Then I Baidu a bit of this problem, found the following several solutions.
Method One: (Modify table) Enter the MySQL database under the Linux system, open the user table, find the record with "host" field value "localhost", and update the value "localhost" to "%".
The order 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 Two: (Authorized) Example 1
If you want to myuser use MyPassword to connect to the MySQL database server from any host. Use the following power of Attorney command:
Grant all privileges on *.* to [email= ' myuser ' @ '% ']%27myuser%27@%27%%27[/email] identified from ' MyPassword ' with GRANT OPTI On;
Example 2
If you want to allow the user to connect to the MySQL database server from the IP-192.168.0.101 host, use MyPassword as the myuser password. Use the following authorization command:
GRANT all privileges on *.* to [email= ' myuser ' @ ' 192.168.0.101 ']%27myuser%27@%27192.168.0.101%27[/email] identified by ' MyPassword ' with GRANT OPTION;
Both of the above methods are found on the Internet. I have solved the problem I encountered by using example 1 of the second method, and successfully connected the MySQL database server in Linux system.
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.