Common failures and reasons for mysql connection failure

Common failures and reasons for mysql connection failure

=====================================================================================================
Fault phenomenon: Unable to connect to mysql
Error message: ERROR 2003 (HY000): Can't connect to MySQL server on 'hostxxxxx' (10061)
Cause: The mysqld database service is not started.
Check: Check in Windows Task Manager, or ps -aux | grep mysql in Unix/Linux. Verify that the service is started.
Processing: Start the mysqld service
=====================================================================================================

==========================================================================
Fault phenomenon: Unable to connect to mysql
Error message: ERROR 1130: Host xx.xx.xx.xx is not allowed to connect to this MySQL server
Reason: The MySQL server does not grant this client permission to connect remotely.
Check: Check whether the host corresponding to the user table in the MySQL database contains the IP address of the client machine (% means no restriction on IP addresses and remote connections are allowed).
Solution: Modify the user table under the mysql database: update user set host = '%' where user = 'XXX'; flush privileges;
====================================================================================

Your user does not use the root account, or your root account does not have login permissions. You need to use
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
Authorization

=====================================================================================================
Fault phenomenon: Unable to connect to mysql
Error message: ERROR 2003 (HY000): Can't connect to MySQL server on 'hostxxxxx' (10061)
Cause: The mysqld client and server ports are inconsistent.
Check: Set the service port in my.ini. This is a common problem, especially when the client port is inconsistent with the remote server port. Solution: Start the mysqld service
=====================================================================================================

Fault phenomenon: Unable to connect to mysql

===================================================================================
Error message: ERROR 2003 (HY000): Can't connect to MySQL server on 'hostxxxxx' (10061)
Cause: The mysqld database service is not started.
Check: Check in Windows Task Manager, or ps -aux | grep mysql in Unix/Linux. Verify that the service is started.
Processing: Start the mysqld service
===================================================================================
Error message: ERROR 1130: Host xx.xx.xx.xx is not allowed to connect to this MySQL server
Reason: The MySQL server does not grant this client permission to connect remotely.
Check: Check whether the host corresponding to the user table in the MySQL database contains the IP address of the client machine (% means no restriction on IP addresses and remote connections are allowed).
Solution: Modify the user table under the mysql database: update user set host = '%' where user = 'XXX'; flush privileges;
===================================================================================
Error message: ERROR 1045 (28000): Access denied for user 'usera'@'localhost' (using password: YES)
Reason: The user account has not been created. Check: After logging in as the administrator ROOT, run show grants for 'usera'@'localhost'; or select user from mysql.user; to confirm whether the user account exists.
Process: Create a user account.
===================================================================================
Error message: ERROR 2003 (HY000): Can't connect to MySQL server on 'hostxxxxx' (10061)
Cause: The mysqld client and server ports are inconsistent.
Check: Set the service port in my.ini. This is a common problem, especially when the client port is inconsistent with the remote server port. Solution: Start the mysqld service
===================================================================================
Error message: ERROR 2002 (HY000): Can't connect to local MySQL server server through socket '/var/lib/mysql/mysql.sock'(111)

Cause: mysqld's mysql.sock is not in the corresponding location.

deal with:

1. First check /etc/rc.d/init.d/mysql status to see if it is started

2. Change permissions chown -R mysql:msyql /var/lib/mysql

3. Modify /etc/my.cnf (Note: stop the database first)

    [mysqld]
    datadir=/usr/local/mysql/data
    socket=/var/lib/mysql/mysql.sock
    [mysql.server]
    user=mysql
    basedir=/usr/local/mysql
    [client]
    socker=/var/lib/mysql/mysql.sock

4. Start the database
===================================================================================

===================================================================================

Common inspection steps.

1. PING hostname or PING 189.xx.xx.xx to confirm that there is no problem with the server IP layer communication. If the PING command succeeds, continue with (2). If the PING command fails, seek help from a network expert.

2. TELNET hostname 3306 confirms that there is no problem with the TCP layer communication with the server. (Your port number may not be 3306). If it works, continue. If it doesn't, check whether mysqld is already running and whether the firewall blocks the port.

3. Check user permissions, show grants ...

You may also be interested in:
  • How to check mysql locks through mysql show processlist command
  • mysql show processlist displays the mysql query process
  • Summary of online MYSQL synchronization error troubleshooting methods (must read)
  • A solution to the MYSQL master-slave out-of-sync problem
  • A MySQL slow query caused a failure
  • Super deployment tutorial of MHA high availability failover solution under MySQL
  • Overview, installation, troubleshooting, tips, and tools of MySQL replication (shared by Huo Ding)
  • Methods for detecting MySQL table failures
  • MySQL SHOW PROCESSLIST assists in the entire process of troubleshooting

<<:  JavaScript design pattern learning proxy pattern

>>:  How to use crontab to add scheduled tasks in Linux

Recommend

Tutorial on Installing Nginx-RTMP Streaming Server on Ubuntu 14

1. RTMP RTMP streaming protocol is a real-time au...

An article to quickly understand Angular and Ionic life cycle and hook functions

Table of contents Angular accomplish Calling orde...

React antd realizes dynamic increase and decrease of form

I encountered a pitfall when writing dynamic form...

How to implement controllable dotted line with CSS

Preface Using css to generate dotted lines is a p...

Basic usage details of Vue componentization

Table of contents 1. What is componentization? 2....

Example of implementing skeleton screen with Vue

Table of contents Skeleton screen use Vue archite...

Causes and solutions to the garbled character set problem in MySQL database

Preface Sometimes when we view database data, we ...

MySQL learning database search statement DQL Xiaobai chapter

Table of contents 1. Simple retrieval of data 2. ...

Vuex implements simple shopping cart function

This article example shares the specific code of ...

Nginx Service Quick Start Tutorial

Table of contents 1. Introduction to Nginx 1. Wha...

CSS implements Google Material Design text input box style (recommended)

Hello everyone, today I want to share with you ho...

Detailed explanation of the workbench example in mysql

MySQL Workbench - Modeling and design tool 1. Mod...