Recently, MySQL was installed on an Amazon cloud host and cannot be accessed remotely. After several pitfalls, the access was successful. Here we will record: EC2
Recently, MySQL was installed on an Amazon cloud host and cannot be accessed remotely. After several pitfalls, the access was successful. Here we will record: EC2
Recently, MySQL was installed on an Amazon cloud host and cannot be accessed remotely. After several pitfalls, the access was successful. Here we will record how to enable remote access after MySQL is installed on EC2.
I. Problems Encountered
To remotely access MySQL on EC2, the following message is displayed:
ERROR 2003 (HY000): Can't connect to MySQL server on 'xx. xx. xx. xx' (111)
Or
Host 'xx. xx. xx. xx' is not allowed to connect to this MySQL server
Ii. Solutions
1. Set the EC2 Firewall
EC2's default firewall blocks all traffic. Therefore, in addition to other necessary rules in EC2's Scurity Groups, you must add an ingress traffic rule: any source IP connection of port 3306 of TCP is allowed.
2. Set User Access in MySql
By default, MySQL only allows access from the local machine. To enable remote access, run the following commands in Terminal:
Mysql-u root-p
Use mysql
Update user set Host = '%' where User = 'root'
In this way, you can access MySql from any IP address.
3. Bind IP addresses in MySQL
Sudo vim/etc/mysql/my. cnf1
Change bind-address 127.0.0.1 to bind-address 0.0.0.0, so that the EC2 IP address can be remotely accessed regardless of the change.
4. Restart MySQL
Sudo/etc/init. d/mysql restart1
The following is the MySQL-related content carefully selected by the editor to see if it is helpful:
Install MySQL 5.6 with the source code in CentOS 7
How to install and configure MySQL5.7.3.0
Install MySQL in Ubuntu 14.04
MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF
Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL
Build a MySQL Master/Slave server in Ubuntu 14.04
Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS
Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04
MySQL-5.5.38 universal binary Installation
This article permanently updates the link address: