I try to configure Wordpress on my Mac. I use an Apache server with MySQL, installed via MacPorts.
So, from phpMyAdmin, I created a "hellowp" user with a "hellowp" database. I can correctly log in with this user, and I have access to the hellowp database.
But when I set these parameters in my wp-config.php, or from the Wordpress configuration GUI, Wordpress can't login to database.
I enabled the debug, and this is the errors I get:
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /private/var/www/hellowp/wp-includes/wp-db.php on line 1342
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /private/var/www/hellowp/wp-includes/wp-db.php on line 1372
Warning: mysql_connect(): No such file or directory in /private/var/www/hellowp/wp-includes/wp-db.php on line 1372
My PHP version is 5.5.10. I use this server for many projects, as some running on Drupal, and I do not have any problem with them.
I also tried to log as MySQL root user in Wordpress, but the error still the same.
EDIT 1 : I tried to log into my server from MySQL Workbench and SURPRISE, the server cannot be found at 127.0.0.1... What's strange is that phpMyAdmin still working, and other projects and Drupal use the database without any problem. I will investigate about that, maybe a firewall issue. Will update when I've got news.
EDIT 2: Ok, so I checked what many of you were telling, and yes many of you were right : MySQL connection from PHP is working only when using PDO (what I do in all of my projects and that Drupal do). mysql_connect and mysqli_connect are triggering an error. But the fact is that I will not rewrite Wordpress, and I'm using the latest version. So I will try to find a solution to make mysql_connect and mysqli_connect work on my PHP configuration.
**EDIT 3: THE SOLUTION: ** I installed Percona server (a MySQL fork) few months ago, to replace mysql server. And during this install, in my php.ini, I setted the socket only for PDO, and not for mysqli and mysql. So, I had to set the socket for all mysql extensions in my php.ini. This is those lines:
pdo_mysql.default_socket="/opt/local/var/run/percona/mysqld.sock"
mysql.default_socket = "/opt/local/var/run/percona/mysqld.sock"
mysqli.default_socket = "/opt/local/var/run/percona/mysqld.sock"
mysqli_connect()
Plus, you can't mix those two APIs – Funk Forty Ninermysql_connect
is deprecated in 5.5 but not deleted. @maxime, please, check/private/var/www/hellowp/wp-includes/wp-db.php
path. Error isNo such file or directory
. – Naeel Maqsudovmysql_*
functions were indeed deleted. @NaeelMaqsudov So, I'm 50% right on this one ;-) – Funk Forty Ninerif ( WP_DEBUG ) { $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); } else { $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); }
– maxime