Solve the MySQL error: 'Can' tconnecttolocalMySQLserverthroughsocke

Source: Internet
Author: User
At the beginning of MySQL compilation and installation, errors always occur after MySQL compilation and installation, which is depressing. I have encountered this problem on several machines. I checked the network today and finally figured out how it was.

At the beginning of MySQL compilation and installation, errors always occur after MySQL compilation and installation, which is depressing. I have encountered this problem on several machines. I checked the network today and finally figured out how it was.

At the beginning of MySQL compilation and installation, errors always occur after MySQL compilation and installation, which is depressing. I have encountered this problem on several machines. I checked the network today and finally figured out what was going on. It turned out that the permission settings were incorrect. Although it was the owner permission, I forgot to set the group. So the error is here. I hope you will have to check and check out the problem of your remarks. It takes so long for you to get it done. Sorry.

The following is an operation record. It will be recorded after make install is complete, and the post will be followed by a netizen's article, forgetting the source. Take it first.

============================

[Root @ localhost mysql] # mysql

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

[Root @ localhost mysql] # service mysqld restart it indicates that mysqld is not started,

MySQL manager or server PID file cocould not be found! [FAILED]

Starting MySQL/etc/init. d/mysqld: line 159: kill: (18977)-No such process

[FAILED]

[Root @ localhost mysql] # cd bin

[Root @ localhost bin] #./mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock '(111) Here we can't use/tmp/mysql. sock connects to the database.

[Root @ localhost bin] # Check the cd/tmp file, and check the file for other reasons.

[Root @ localhost tmp] # ls

Gconfd-root mapping-root mysql. sock mysql-test-ports mysql-test-ports.sem scim-panel-socket: 0-root VMwareDnD vmware-root vmware.txt

[Root @ localhost tmp] # cd/usr/local/mysql/

[Root @ localhost mysql] # pwd

/Usr/local/mysql

[Root @ localhost mysql] # chown-R root: mysql. I suddenly remembered that I didn't set the permission and started to set the permission.

[Root @ localhost mysql] # ll

Total 36

Drwxr-xr-x 2 root mysql 4096 Nov 28 bin

Drwxr-xr-x 3 root mysql 4096 Nov 28 include

Drwxr-xr-x 2 root mysql 4096 Nov 28 info

Drwxr-xr-x 3 root mysql 4096 Nov 28 lib

Drwxr-xr-x 2 root mysql 4096 Nov 28 libexec

Drwxr-xr-x 4 root mysql 4096 Nov 28 man

Drwxr-xr-x 8 root mysql 4096 Nov 28 mysql-test

Drwxr-xr-x 3 root mysql 4096 Nov 28 share

Drwxr-xr-x 5 root mysql 4096 Nov 28 SQL-runtime

[Root @ localhost mysql] # chown-R mysql/var/lib/mysql

[Root @ localhost mysql] # cp share/mysql/my-huge.cnf/etc/my. cnf

[Root @ localhost mysql] # cp share/mysql. server/etc/rc. d/init. d/mysqld

[Root @ localhost mysql] # chmod 755/etc/rc. d/init. d/mysqld

[Root @ localhost mysql] # chkconfig -- add mysqld

[Root @ localhost mysql] # chkconfig -- level 345 mysqld on

======= Error ========

[Root @ localhost mysql] # mysqladmin-u root password 'uplooking'

Mysqladmin: connect to server at 'localhost' failed

Error: 'Can't connect to local MySQL server through socket '/tmp/mysql. sock' (111 )'

Check that mysqld is running and that the socket: '/tmp/mysql. sock' exists! It is the same as the above errors.

[Root @ localhost mysql] # bin/mysql start

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

[Root @ localhost mysql] #/etc/rc. d/init. d/mysqld status

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.