Mysql set up a variety of methods for remote Access database _mysql

Source: Internet
Author: User
Tags iptables

May be IP is not set good

Problem: MySQL permissions are set correctly, but still cannot be accessed remotely. The 3306 port was not opened by Telnet.

Analysis: MySQL defaults to bind only 127.0.0.1, that is, only on this computer to access Port 3306.

Workaround: Locate the MySQL profile, search for "bind-address" and find this line:

bind-address = 127.0.0.1 Add a # in front, comment out this line, save, restart MySQL. Again, remote access is available, and Telnet can discover that the port is also open.

Example we configure

1. Make sure skip-networking is deleted or blocked, otherwise TCP/IP access is not supported
2. Add line bind-address = 65.55.55.2, replace 65.55.55.2 for your server address

After modification, configure to:

Copy Code code as follows:

[Mysqld]
user = MySQL
Pid-file =/var/run/mysqld/mysqld.pid
Socket =/var/run/mysqld/mysqld.sock
Port = 3306
Basedir =/usr
DataDir =/var/lib/mysql
Tmpdir =/tmp
Language =/usr/share/mysql/english
Bind-address = 65.55.55.2
# skip-networking
....
..

Save and close the configuration file
Restart MySQL server: #/etc/init.d/mysql restart


If the above method is not used, we can set the MySQL command mode in general

1. Change Table method.

Your account may not be allowed to log in remotely, only in localhost. This time as long as the computer in localhost, login mysql, change the "MySQL" Database in the "User" table in the "host" item, from "localhost" renamed "%"

Copy Code code as follows:

Code:mysql-u root-p123
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root ';
Mysql>select host, user from user;

2. Authorization law.

For example, you want Kevin to use MyPassword to connect to a MySQL server from any host.

Copy Code code as follows:
Grant all privileges in *.* to ' Kevin ' @ '% ' identified by ' MyPassword ' with Grant OPTION;

If you want to allow user Kevin to connect to the MySQL server from IP for 192.168.101.234 host, and use MyPassword as password

Copy Code code as follows:

Grant all privileges on *.* to ' Kevin ' @ ' 192.168.101.234 ' identified by ' MyPassword ' with GRANT OPTION;

Note that it's important to have a Linux system firewall, too.

Copy Code code as follows:

/* Close Firewall/*
Service Iptables Stop
/* Open the firewall * *
Service Iptables Start
/* Default shutdown Firewall/*
Chkconfig iptables off

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.