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

Sample code using vue-router in html

Introducing vue and vue-router <script src=&qu...

Steps to install GRUB on Linux server

How to Install GRUB for Linux Server You cannot u...

Specific use of CSS content attribute

The content attribute is generally used in the ::...

A brief discussion on the understanding of TypeScript index signatures

Table of contents 1. What is an index signature? ...

In-depth understanding of the creation and implementation of servlets in tomcat

1. What is a servlet 1.1. Explain in official wor...

Exploration and correction of the weird behavior of parseInt() in js

Background: I wonder if you have noticed that if ...

Solution to uninstalling Python and yum in CentOs system

Background of the accident: A few days ago, due t...

HTML simple web form creation example introduction

<input> is used to collect user information ...

React High-Order Component HOC Usage Summary

One sentence to introduce HOC What is a higher-or...

Execution context and execution stack example explanation in JavaScript

JavaScript - Principles Series In daily developme...