admin管理员组文章数量:1390618
my site started acting up a few days ago, running the debug I get these lines.
Tried to mess around with the DB but couldn't get my head through it.
Do you have any idea what those lines imply?
Warning: mysqli_real_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u420302506/public_html/wp-includes/wp-db.php on line 1490
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u420302506/public_html/wp-includes/wp-db.php on line 1520
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u420302506/public_html/wp-includes/wp-db.php on line 1520
Line 1490:
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
Line 1520:
this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
my site started acting up a few days ago, running the debug I get these lines.
Tried to mess around with the DB but couldn't get my head through it.
Do you have any idea what those lines imply?
Warning: mysqli_real_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u420302506/public_html/wp-includes/wp-db.php on line 1490
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u420302506/public_html/wp-includes/wp-db.php on line 1520
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u420302506/public_html/wp-includes/wp-db.php on line 1520
Line 1490:
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
Line 1520:
Share Improve this question asked Apr 27, 2017 at 20:59 Densetsu_NoDensetsu_No 211 silver badge2 bronze badges 1this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
- Which version of WordPress you're using ? – Abdul Awal Uzzal Commented Apr 27, 2017 at 21:36
5 Answers
Reset to default 2I had this same error. For me, this happened because I moved the datadir of my database.
On centos - the default location of the datadir is /var/lib/mysql - and the default loc of the socket file is /var/lib/mysql/mysql.sock
I moved the datadir to /datadir/mysql. The Mysql db server started fine and the 'mysql' command line client worked fine.
However, when I started apache and then accessed my wordpress site, I got that error.
The fix was to update /etc/php.ini.
There are three settings in that file for the mysql.sock location for: - pdo - mysql - mysqli
Below are the changes I made for those three settings - to set each one to "/datadir/mysql/mysql.sock". Prior to my change, all three were just blank after the '=', and so the default location was used.
[Pdo_mysql]
...
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php/pdo_mysql.default-socket
pdo_mysql.default_socket=/datadir/mysql/mysql.sock
[MySQL]
...
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php/mysql.default-socket
mysql.default_socket = /datadir/mysql/mysql.sock
[MySQLi]
...
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php/mysqli.default-socket
mysqli.default_socket = /datadir/mysql/mysql.sock
The error messages show signs of mismatch between your wordpress version and your PHP (or even mysql) version. Sounds like you are trying to run old wordpress version on new php version, or that you do not have mysqli extension of PHP active.
This will explain the last two errors, but not the first one. The first one seems to be a sign that either mysql and its relevant drivers are misconfigured or that the mysql just shutsdown from time to time.
If you are on a shared hosting, call their support, if it is your own VPS you need to get someone to check out your setup (assuming you have enough memory to handle your load).
Try to replace your current host from localhost to 127.0.0.1
in your wp-config.php. If you can then try to restart your MYSQL services.
Try using the IP address of your local server instead of localhost
. That means set 127.0.0.1
at DB_HOST
in wp-config.php
. So the full thing will be like-
/** MySQL hostname */
define('DB_HOST', '127.0.0.1');
Check those below answers for more information-
https://stackoverflow/questions/13769504/mysqlimysqli-hy000-2002-cant-connect-to-local-mysql-server-through-sock
https://stackoverflow/questions/4219970/warning-mysql-connect-2002-no-such-file-or-directory-trying-to-connect-vi
In Wordpress I was having a problem between mysqli and PDO. I solved it with the command yum update & yum upgrade, no centos and he gave me the following updates:
================================================== ============================== Package Arch Version Repository Size ================================================== ============================== Installing: lsphp73-mysqlnd x86_64 7.3.15-1.el7 litespeed 132 k replacing lsphp73-mysqlnd.x86_64 7.3.14-1.el7 Updating: lsphp73 x86_64 7.3.15-1.el7 litespeed 5.0 M lsphp73-bcmath x86_64 7.3.15-1.el7 litespeed 27 k lsphp73-common x86_64 7.3.15-1.el7 litespeed 650 k lsphp73-gd x86_64 7.3.15-1.el7 litespeed 114 k lsphp73-imap x86_64 7.3.15-1.el7 litespeed 32k lsphp73-mbstring x86_64 7.3.15-1.el7 litespeed 559 k lsphp73-opcache x86_64 7.3.15-1.el7 litespeed 191 k lsphp73-pdo x86_64 7.3.15-1.el7 litespeed 67 k lsphp73-process x86_64 7.3.15-1.el7 litespeed 29 k lsphp73-soap x86_64 7.3.15-1.el7 litespeed 120 k lsphp73-xml x86_64 7.3.15-1.el7 litespeed 126 k openlitespeed x86_64 1.6.9-1.el7 litespeed 37 M
Transaction Summary ================================================== ============================== Install 1 Package Upgrade 12 Packages
Total download size: 44 M Downloading packages: No Presto metadata available for litespeed
Total 13 MB / s | 44 MB 00:03
Besides that mine fastcgi_pass unix: /var/php-nginx/15822663384347.sock/socket;
It was causing conflict.
but it still didn't solve the problem.
The solution found was to change the username and password in the file that connects the cms with the database and I saw that suddenly it could be the username that has a dot or is the same domain name.
本文标签: mysqlError establishing a database connectionwith Debug Data
版权声明:本文标题:mysql - Error establishing a database connection - with Debug Data 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744724396a2621881.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论