MySQL database connection failed sqlstate[hy000] [2003] Can ' t connect to MySQL server on ' 127.0.0.1 ' (13)

Source: Internet
Author: User



Centos6.5x64 Install Zen Road 6.2, generate configuration file, database connection failed








Database connection failed sqlstate[hy000] [2003] Can ' t connect to MySQL server on ' 127.0.0.1 ' (13)



Root, the password must not be wrong (command line can login), with the 127.0.0.1







PHP is installed properly, MySQL configuration is correct, PHP PDO, MySQL extension correct, use




<?php
$link=mysql_connect('localhost','root','password');
if ($link)
echo "successfu";
else
echo "Faile";
mysql_close();
?>

PHP code can properly connect to the database, but the installation of Zen channel is always not connected to the MySQL database Can ' t connect to MySQL server on ' 127.0.0.1 ', a variety of reasons for analysis without fruit, and finally carefully read the my.cnf file, found mysqld with user=mysql information, as follows:






[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

will user=mysql this as User=rootAfter restarting the MYSQLD service after installing everything normal, official parameter explanation:








MYSQLD program will be executed under a given Unix/linux account after launch; Mysqld must be started from the root account in order to switch to another account after booting; The Mysqld_safe script will use the –USER=MYSQL option by default to start the MYSQLD program.












For specific parameters, please refer to: MySQL configuration parameters detailed



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.



MySQL database connection failed sqlstate[hy000] [2003] Can ' t connect to MySQL server on ' 127.0.0.1 ' (13)


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.