Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.socket

Source: Internet
Author: User

First, solve Var/run/mysqld no PID and sock files

MySQL Mysql.sock lost because of the cause of the loss is generally due to inconsistent configuration files, mysqld error starts, Mysqld_safe will clear the mysql.sock. The workaround is to:

It is not possible to create/tmp/mysql.sock and hostname.pid files because the normal person does not switch to the MySQL user when resolving the failure, causing permissions problems and unable to create the MySQL authorization table. Therefore, the summary solution is as follows:

#su mysql//root user is also possible

$/usr/local/bin/mysql_install_db//To Bin directory execution, rebuild authorization form

$/usr/local/bin/mysqld_safe &

MYSQL-UROOT-P//test

mysq>bye;

$

Files have been resolved to regenerate new/tmp/mysql.sock and Hostname.pid

var/

$SU Root

Second, resolve the Mysql.sock file path is not correct

1. Create a link:ln-s/var/lib/mysql/mysql.sock/path/to/mysql/mysql.sock in/var/lib/mysql

2. Under root permissions, modify the My.cnf file (/etc/mysql/my.cnf) to specify the correct path

Either 3.1 and 2 can be selected

Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.socket

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.