Mysql connection not working on new server!

We are setting up a new server to handle some of the services of our site.
And the Mysql connection is not working via Php which works fine from our other (older) sites.
1- on new server we have: PHP 5.4.16 (cli) (built: Apr 1 2020 04:07:17)
2- on old we have: PHP 5.3.3
3- We have checked that mysql access is working fine on new server via:
mysql -u root -p

but when trying to connect to Mysql via php via either of these commands, it is not connecting:

$con = @mysql_connect(‘localhost’, ‘root’, ‘xyz123’); {from other older servers}

and also tried this:
$con = mysqli_connect(‘localhost’, ‘root’, ‘xyz123’);

And have checked the php.ini and Mysql related connections are there

What to do to fix this please?


To be honest, the first thing you need to do is get current Php. You are hundreds upon hundreds of releases behind the current version. If you have legacy apps that will only run on old Php then you need to refactor or re-write your scripts. They would most definitely be insecure.

#1: Recommend you upgrade the server to something reasonably recent. 5.4.16 was not built April 1 2020, it was built June 6 2013. The server may have been created in 2020, but your PHP version is now 3 Major versions out of date. 8.0 was released Nov 26, 2020.

#2: mysql_ library has been removed from PHP for some time. Suggest you advance to PDO.

right, now that the “You shouldnt do this” is out of the way…

what does echo mysqli_connect_error() say?

1 Like

1st, what is the latest version of Php you recommend we upgrade to?

2nd, we cannot break the current Php/Mysql code that we have which runs into Millions of lines

3rd, says: mysqli_connect_error()
Authentication plugin ‘caching_sha2_password’ cannot be loaded: /usr/lib64/mysql/plugin/ cannot open shared object file: No such file or directory


Here you see the current status of PHP versions and ones that are currently supported. Ideally, you want one in green.

FYI, we fixed that problem
Fix was done by setting Mysql

1 Like

I run a Ubuntu 20.04 VPS Server with PHP 8.02 and a recent update failed to start MySQL. Fortunately a reboot cleared the problem. Scratching around various log files trying to pinpoint the problem is never easy.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.