"Can & #039; t connect to local MySQL" prompt

Source: Internet
Author: User

I encountered a problem connecting to the mysql database today: Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)

Solution 1.

1. # ps-A | grep mysql

Display is similar:

1829? 00:00:00 mysqld_safe

1876? 00:00:31 mysqld

2. # kill-9 1829

3. # kill-9 1876

4. #/etc/init. d/mysql restart

5. # mysql-u root-p

His troubles have been solved, and I have not solved it yet!

Continue searching

Solution 2

Check/etc/rc. d/init. d/mysqld status to see if m y s q l has been started.

Check whether the permission is correct.

Bytes ------------------------------------------------------------------------------------

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

[Root @ localhost beinan] #/etc/init. d/mysqld start

Start MySQL: [OK]

[Root @ localhost lib] # mysqladmin-uroot password '123'

[Root @ localhost lib] # mysql-uroot-p

Enter password:

Welcome to the MySQL monitor. Commands end with; or/g.

Your MySQL connection id is 3 to server version: 4.1.11

Type 'help; 'or'/H' for help. type'/C' to clear the buffe

He has also solved the problem. I am still in trouble and continue to look for it.

Solution 3

After the problem is solved, it turns out that max_connections = 1000 has said too much, and then he changed it to 500 and said too much, but he had no choice but to delete the problem.

Still not good

Solution 4

/Var/lib/mysql change all file permissions to mysql. mysql

No.

Solution 5

Abstract: mysql cannot be used. the main cause of sock connection to MySQL is that it cannot pass '/tmp/mysql. the sock is connected to the server, and the php standard configuration has been used '/tmp/mysql. sock, but some mysql installation methods will be mysql. put sock in/var/lib/mysql. sock or somewhere else, you can modify/etc/my. modify the cnf file and open the file. You can see the following:

[Mysql d]

Socket =/var/lib/mysql. sock

Just change it, but it will also cause other problems. For example, if the mysql program cannot be connected, add one more point:

[Mysql]

Socket =/tmp/mysql. sock

You can also modify the configuration in php. ini to connect php to another mysql. sock.

Or use the following method:

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

If the call succeeds, ln-s/var/lib/mysql. sock/tmp/mysql. sock

OK!

However, my system does not find the mysql. sock file, only the mysqld. sock file,/var/run/mysqld. sock

As a result, follow the above practice: ln-s/var/run/mysqld. sock/tmp/mysql. sock

In this way, you can connect to the database normally ..

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.