The new installation of MySQL and can not be remotely connected to the server, you need the following steps to resolve
0. View the port open case
- Ali cloud the 3306 port security group is set to 0.0.0.0/0, open to all
- Confirm that you can connect through port scanning tool: port scanning tool
- Login server,
netstat -an | grep 3306
see MySQL's operation and monitor the situation, we found that 3306 port is listening only on the local
root@iZbp12kno11kc9e34bktfaZ:/var/log/mysql# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
1. open port and restart
- MySql modify the configuration file, open port listening
vim /etc/mysql/mysql.conf.d/mysqld.cnf
...
# bind-address = 127.0.0.1 //注释掉这行
...
- Restart MySQl
service mysql restart
- View the port status monitor
netstat -an | grep 3306
tcp6 0 0 :::3306 :::* ISTEN
Now has access to the external port 3306, but in order to connect MySQL, you need to configure a remote connection permissions have an account "local connection is the default root privileges."
Configuring the remote user is connected
// 创建用户
mysql> create user arong;
Query OK, 0 rows affected (0.00 sec)
// 为用户配置全部权限
mysql> grant all privileges on *.* to arong@'%' identified by '123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
// 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
After completion of the above can be used to connect remote users of the MySQL server.