All Products
Search
Document Center

Common errors and solutions

Last Updated: Sep 21, 2020

Overview

This article describes common errors and solutions when you cannot connect to a MySQL server that is built on an ECS instance running Linux.

 

Description

The following are some common problems and solutions.

 

Connection to the MySQL service fails due to unauthorized authorization

Problem

When you connect to the MySQL service within the ECS instance, the following error occurs during the remote connection.

EHost 'XX.XX.XX.XX' is not allowed to connect to this MySQL serverConnection closed by foreign host.

A similar output is displayed.

 

Solution

  1. Check that the MySQL service listens0.0.0.0Address.
  2. Check whether the firewall is enabled for the instance. We recommend that you disable the firewall first.
  3. To check whether remote logon is enabled for the MySQL service, perform the following steps.
    • Log on to the database and select the mysql database. Change the host item in the user table from localhost'%'.
    • Log on to the database and create a remote user.

 

Unable to connect to the MySQL service due to incorrect listening address

Problem

MySQL service pair127.0.0.1Address for listening, causing external connection failure.

 

Solution

In the MySQL service configuration file, comment out the bind-address parameter, and then restart it.

 

Lost connection to MySQL server at 'reading initial communication packet', system error:

 

Problem

The following error is reported when you connect to the MySQL service remotely.

Lost connection to MySQL server at 'reading initial communication packet', system error: 

 

Solution

  1. Check whether the firewall is enabled to restrict connection requests.
  2. Check whether the MySQL database has access permissions. Run the following command.
    use mysql;
    Grant all privileges on *.* to 'root'@'%' identified by '[$Password]' with grant option;
    flush privileges;
    Note: [$ Password] is the Password.
  3. Check whether the bind-address parameter is set in the my. ini configuration file. Annotate this parameter.
  4. Add the skip-name-resolve parameter to the my. ini configuration file.
  5. Modify the hosts. allow configuration file and add the following configuration.
    mysqld-max : ALL :ALLOW

 

Unable to connect to the MySQL service due to version issues

Problem

If the version of the user-created MySQL server is 5.6, the following error message is displayed during remote connection.

ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

 

Causes

The password management protocol on the server is outdated and the old user password format is used for storage. However, the new password format is used after the client is upgraded. MySQL 5.6 rejects the connection if this inconsistency occurs.

 

Solution

Add when connecting-- Secure-authParameter. The connection command is as follows. For more information, seeMySQL manual.

mysql -h [$Host] -u [$Username] --secure-auth -p

Note: [$ Host] is the ECS instance domain name or IP address, and [$ Username] is the database Username.

 

If the problem persists, you can receive a free consultation in Alibaba Cloud Community or submit a ticket to contact Alibaba Cloud technical support personnel.

 

Application scope

  • ECS