Mysql error-Modify mysql. sock location, mysqlmysql. sock

Source: Internet
Author: User

Mysql error-Modify mysql. sock location, mysqlmysql. sock

Sometimes Mysql. sock location errors may occur in mysql, resulting in the inability to connect to the database.

When an error is reported in mac:


First modify my. cnf

The location is under/etc/my. cnf. If not, modify it under/usr/locate/mysql/my. cnf and copy it to/etc.

To:

[client]socket = /tmp/mysql.sock[mysqld]socket = /tmp/mysql.sock

If there is no [client], add it yourself ~


Then restart the mysql service and open mysql to see if the location has changed ~ Use, view status

mysql  Ver 14.14 Distrib 5.6.17, for osx10.7 (x86_64) using  EditLine wrapperConnection id:24Current database:Current user:root@localhostSSL:Not in useCurrent pager:lessUsing outfile:''Using delimiter:;Server version:5.6.17 MySQL Community Server (GPL)Protocol version:10Connection:Localhost via UNIX socketServer characterset:utf8Db     characterset:utf8Client characterset:utf8Conn.  characterset:utf8UNIX socket:/tmp/mysql.sockUptime:15 min 51 sec

If php. ini (the location is/etc/php. ini) is not found, copy a php. ini. default file.

In:

pdo_mysql.default_socket=/tmp/mysql.sockmysql.default_socket = /tmp/mysql.sockmysqli.default_socket = /tmp/mysql.sock

All three are modified ~

Then

sudo apachectl stopsudo apachectl start

You can ~

Check whether mysql. sock has changed under phpinfo ~


Q: How to change the mysql directory in linux? Is there a lot of documents saying that you want to change the mysqlsock path? Is this required? Is it not affected if it is not changed?

Mysql. by default, sock is in/var/lib/mysql. If the directory has insufficient permissions, mysql cannot run because the file cannot be created. You can add mysql under [mysqld. sock path
Vi/etc/my. cnf

[Mysqld]
Port = 3306
Socket =/var/lib/mysql. sock
...

Mysqlsock is not located in/tmp. How can I fill in the database server when DZ is installed?

Coshep is a case. Another case is that there may be two MYSQL instances in your system, but the my. cnf file is not correctly loaded at startup.
Check whether the datadir position in my. cnf is correct.

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.