Virtual machine Linux side Mysql database cannot be accessed remotely solution _mysql

Source: Internet
Author: User

For the solution of the virtual machine Linux side MySQL database can not be remote access one of the following content I have to organize two solutions, the details are as follows:

Workaround One:

1, in the console execution Mysql-u root-p mysql,centos system prompts to enter the database root user's password, the input completes then enters the MySQL console

2. Execute GRANT all privileges in MySQL console *.* to ' root ' @ '% ' identified by ' MyPassword ' with Grant OPTION; FLUSH privileges;

3, in the MySQL Console Executive command of the ' root ' @ '% ' can be understood in this way: root is the user name,% is the host name or IP address, where the% represents any host or IP address, you can also replace any other user name or specify a unique IP address; ' MyPassword ' is the password for the login database specified by the authorized user; and what I need to say is that I'm here to authorize all permissions to specify partial rights

4, switch to root user to open Iptables profile: vi/etc/sysconfig/iptables

Add Red Font

# Firewall configuration written by System-config-firewall
# Manual Customization to this file is not recommended.
   
    *filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m State--state Establi Shed,related-j ACCEPT
-a input-p icmp-j ACCEPT-a
input-i lo-j ACCEPT
-a input-m state--state new-m TC P-p TCP--dport 22-j ACCEPT
-a input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
-a input-j REJ ECT--reject-with icmp-host-prohibited
-A forward-j reject--reject-with icmp-host-prohibited
COMMIT
   

Restart iptables:service iptables restart after all modifications are completed

You can verify that the rules are in effect:iptables-l this way ,

We have completed the CentOS firewall settings modification.

In remote: mysql-h 192.168.16.128-u root2-p Enter password Root2 success ~

Workaround Two:

For details, please see the following code:

Mysql-uroot-p
Enter Password: 
mysql>grant all privileges on *.* to ' root ' @ '% ' identified by ' sy31214 ' with GR ANT OPTION;
Mysql>flush privileges;

The above is the entire content of this article, for the virtual machine Linux MySQL database can not be remote access to the solution there are many kinds of, welcome you to share their own master of the solution, this article is not good, look at a lot of suggestions for criticism.

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.