0

After a failed Wordpress upgrade I got the error

Warning: mysqli_real_connect(): (HY000/1045): Access denied for user...

So I reinstalled WP, but still getting the same error. The strange thing is I can connect to the mysql server (remote host) via the mysql shell (on the same PHP server), just not via PHP. So doesn't seem to be a credentials/firewall issue.

I tried it with a separate script with only the mysqli_connect(), but also no luck. I replaced the server host name with an IP, also did not work.

PHP: 7.0

Edit: It turned out that the mysql server required a ssl connection, so I had to add define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL); to wp-config.php.

Daniel
  • 49
  • 1
  • 4
  • You should upgrade as soon as possible. This version of PHP hasn't been supported for few years. – Dharman Apr 02 '20 at 22:04

1 Answers1

-2

I had a similar problem at one stage. My fix came when i added the port extension to my localhost. Like this:

mysqli_connect(localhost:3307, "root", "", "$db_name").

Try and establish which port your statement is attempting to make a connection with. 3308, 3307, 3306

Dharman
  • 30,962
  • 25
  • 85
  • 135
DamDam
  • 1