Can't connect to local MySQL through socket '/tmp/mysql.sock' solution

Can't connect to local MySQL through socket '/tmp/mysql.sock' solution

Error message:

ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)

Solution:

/usr/local/mysql/bin/mysqladmin -u root > -S /var/lib/mysql/mysql.sock password 'your.passwd'

Or make a soft link

ln -s /var/lib/mysql/mysql.sock /tmp

reason:

In fact, the prompt that /tmp/mysql.sock cannot be found sometimes does not mean that the file does not exist in the /tmp directory, but that the startup command is incorrect.

/usr/local/mysql/bin/mysql -u root -p
/usr/local/mysql/bin/mysqld --user=mysql&
/usr/local/mysql/bin/mysqld --user=root&
/usr/local/mysql/bin/mysqld_safe --user=root&
/usr/local/mysql/bin/mysqld_safe --user=mysql&
/usr/local/mysql/bin/safe_mysqld--uer=root& (note that safe_mysqld is different from mysqld_safe, & means mysql is running in the background)

Error message:

STOPPING server from pid file /usr/local/mysql/data/localhost.localdomain.pid 060304 11:46:21 mysqld ended

Solution:

This is a permission issue. My mysql directory belongs to the root user and the root group. I can start it with mysqld_safe and it works fine. Just pay attention to these commands: mysql, safe_mysqld, mysqld_safe, mysqld, mysqladmin. Try several times. Sometimes mysql has started normally. Check whether mysql is started with the command

ps -aux | grep mysqld

You will see something similar to the following

mysql 6394 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/mysql 6395 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/mysql 6396 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/root 6422 0.0 1.1 2408 732 pts/3 S 16:20 0:00 grep mysql

Check if mysql is listening on the port command

netstat -tl | grep mysql

You will see something similar to the following

tcp 0 0 *:mysql *:* LISTEN

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Python chat room with interface implementation example code (tkinter, Mysql, Treading, socket)
  • ERROR 2002 (HY000): Can't connect to local MySQL server through socket ''/tmp/mysql.sock''
  • Java+jdbc+mysql+socket to build a LAN chat room
  • Java Socket+mysql to implement simple file uploader code
  • Detailed explanation of the function of mysql socket file
  • MySQL error ERROR 2002 (HY000): Can't connect to local MySQL server through socket
  • MySQL HandlerSocket plugin installation and configuration tutorial
  • How to solve the problem that MySQL cannot start because it cannot create PID
  • In-depth analysis of the reason why the error "The server quit without updating PID file" is reported when MySQL is started
  • MySQL startup error MySQL server PID file could not be found
  • Solution to the problem of missing pid file after Mysql crashes and cannot be restarted
  • Solutions to MySQL PID file loss related errors
  • mysql: Can't start server: can't create PID file: No space left on device
  • MySQL Tips: Solution to the problem of server quit without updating PID file
  • linux mysql error: MYSQL: The server quit without updating PID file
  • Solution for Starting MySQL.Manager of pid-file quit without updating file.[FAILED]
  • Detailed explanation of pid and socket in MySQL

<<:  Detailed explanation of the execution process of JavaScript engine V8

>>:  Detailed explanation of the application of Docker underlying technology Namespace Cgroup

Recommend

MySQL briefly understands how "order by" works

For sorting, order by is a keyword we use very fr...

Deeply understand how nginx achieves high performance and scalability

The overall architecture of NGINX is characterize...

Zabbix WEB monitoring implementation process diagram

Take zabbix's own WEB interface as an example...

JavaScript singleton mode to implement custom pop-up box

This article shares the specific code of JavaScri...

Introduction and usage of Angular pipeline PIPE

Preface PIPE, translated as pipeline. Angular pip...

Example analysis of MySQL startup and connection methods

Table of contents How to start mysqld Method 1: m...

Detailed explanation of fetch network request encapsulation example

export default ({ url, method = 'GET', da...

MySQL Optimization: InnoDB Optimization

Study plans are easily interrupted and difficult ...

MySQL service and database management

Table of contents 1. Start and stop service instr...

How to install and deploy gitlab server on centos7

I am using centos 7 64bit system here. I have tri...