Can 'tconnecttolocalmysqlserverthroughsocket problem solved

Source: Internet
Author: User
After mysql is installed in Linux5.6, run the mysql command to report the following error: ERROR2002 (HY000): Can

After mysql is installed on the Linux 2002 system, run the mysql command to report the following ERROR: ERROR (HY000): Can

The following error is reported when you execute the mysql command after installing mysql in Linux5.6:

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

1. Check/etc/rc. d/init. d/mysqld status to see if the mysql service has been started.
Check whether the permission is correct.
$ Service mysqld start
Or
$ Service mysql start
-- I first encountered a problem because the service was not started, because I was not very familiar with mysql for the first time.

2. Check whether your mysql. sock is in that location,
Mysql-u your mysql username-p-S/var/lib/mysql. sock

3. If the permission problem occurs, change the permission first # chown-R mysql: mysql/var/lib/mysql

[Root @ localhost ~] #/Etc/init. d/mysqld start
Start MySQL: [OK]
[Root @ localhost ~] # Mysql-uroot-p

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)
The reason is that the access permission of/var/lib/mysql is incorrect.

Shell> chown-R mysql: mysql/var/lib/mysql

Start the server.

Shell>/etc/init. d/mysql start

After the server is started normally, check/var/lib/mysql to automatically generate the mysql. sock file.

4. Modify/etc/my. conf:
[Mysqld]
Datadir =/usr/local/mysql/data
Socket =/var/lib/mysql. sock

[Mysql. server]
User = mysql
Basedir =/usr/local/mysql

If there is not currently a section called [client], add one at the bottom of the file and copy the socket = line under the [mysqld] section such:

[Client]
Socket =/var/lib/mysql. sock

If the problem persists, run/etc/init. d/mysql start and report the following error: Starting MySQLCouldn't find MySQL manager or server.
If the mysqld service is not enabled, run/usr/local/mysql/bin/mysqld_safe &

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.