Cartika Support Portal

            Wordpress error establishing a database connection

            First create testconn.php Fill it with the actual db connection string from either wp-config.php or from the client himself.
            $link = mysql_connect('localhost', 'root', 'password');
            if (!$link) {
            die('Could not connect: ' . mysql_error());
            echo 'Connected successfully';

            IF the error shows as :

            Could not connect: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file

            You have to reset the password for the mysql user to at 10+ alphanumeric characters e.g. for this client I reset the password to v6dkUd26PbR4w on mysql server I adjusted with following command, furthermore also updated wp-config.php accordingly.
            mysql> UPDATE mysql.user SET Password = PASSWORD('v6dkUd26PbR4w') WHERE user = 'testdbuser_wp';
            Query OK, 1 row affected (0.01 sec)
            Rows matched: 2  Changed: 1  Warnings: 0

            mysql> FLUSH PRIVILEGES;
            Query OK, 0 rows affected (0.02 sec)

            Finally feel free to remove, if you want.
            Updated: 24 Jun 2018 01:37 PM
            Help us to make this article better
            1 1