Focus on cloud service provider activities
Notes on website operation and maintenance

Solve the problem that mysql.sock cannot find in the server and the solution

Today, when I was in the O&M server, I was prompted that mysql.sock could not find the problem. Let's see how to solve it. Here is a prompt when running and restarting MySQL“

 cant connect to mysql server through socket '/tmp/mysql.sock'

It seems that this file does not exist.

 Solve the problem that mysql.sock cannot find in the server and the solution

Use the command find/- name mysql.sock to check whether the file exists globally. Here we use the find command to find the location of this file. If find cannot find it, restart the MySQL service and regenerate one. Then copy it to the path specified by the sortek parameter. Or you can establish a soft connection. For example, this file is in/var/lib/mysql.sock. The path specified by the socket parameter is/tmp/mysql.sock.

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

For the path of the sock file, we can see it in/etc/my.cnf.

 #Set the installation directory of MySQL basedir = /usr/local/mysql #Set the storage directory of MySQL database data datadir = /usr/local/mysql/data character-set-server=utf8 #Maximum connections allowed max_connections=200 port = 3306 # server_id = ..... socket = /tmp/mysql.sock #The default storage engine that will be used when creating new tables default-storage-engine=INNODB # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M  #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #explicit_defaults_for_timestamp=true

You can see the location of mysql.sock through this command.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( one )
Do not reprint without permission: Lao Zuo's Notes » Solve the problem that mysql.sock cannot find in the server and the solution


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge