MySQL note-The simplest way to troubleshoot problems that cannot find the Mysqld.sock file

Source: Internet
Author: User

First of all, the environment: Ubuntu 14.04, installed in a apt-get way, manual installation may have a slightly different path setting.

1, after the installation of MySQL, the first time with the command line to find the Mysqld.sock file is not found, prompt:

ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock ' (2),

2, the method of the Internet is not practical, here is a simple way to solve the problem.

# sudo/etc/init.d/mysql Restart

3, Detours:

[Email protected]:/# mysql-uroot-p

Enter Password:

ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock ' (2)

[Email protected]:/opt#cd/var/run/mysqld/

[Email Protected]:/var/run/mysqld#ls

[Email protected]:/var/run/mysqld#

The inside is empty, lacks the mysql-client?

[Email protected]:/var/run/mysqld#apt-get Install mysql-client


[Email protected]:/opt#cd/var/run/mysqld/

[Email Protected]:/var/run/mysqld#ls

Or nothing, change the command to start:

[Email protected]:/var/run/mysqld#service mysqld Start

Mysqld:unrecognized Service

Find the root of the problem in:/etc/mysql/my.cnf

[Email PROTECTED]:/ETC#CD mysql/

[Email Protected]:/etc/mysql#ls

CONF.D debian.cnf Debian-start my.cnf

[Email Protected]:/etc/mysql#vim my.cnf

Here are the settings for Mysqld.sock, which is not found when MySQL follows this default setting.

If changing the path problem here can be cumbersome, use the following approach to solve the problem:

[Email protected]:/#sudo/etc/init.d/mysql restart

*stopping MySQL database Server mysqld [OK]

*starting MySQL database Server mysqld [OK]

*checking for tables which need an upgrade, is corrupt or were

notclosed cleanly.

[Email protected]:/#mysql-uroot-p

Enterpassword:

Welcometo the MySQL Monitor. Commands End With; or \g.

Yourmysql Connection ID is 43

。。。。。。

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current inputstatement.

Mysql>

OK, Fix it.

MySQL note-The simplest way to troubleshoot problems that cannot find the Mysqld.sock file

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.