wordpress and php mysql database connection issue

I am trying to install wordpress into my system at fedora 17. I am getting error with database connectivity:

Error establishing a database connection

Read More

I have done below troubleshooting.

  1. I have tried with command prompt to connect mysql database with same credentials and its connected successfully.

  2. Than I tried to connect to database directly using php using below code.

    <?php
    $db = @mysql_connect('localhost', 'wpuser', 'wppassword');
    if (!$db) echo "connection failed --". mysql_error();
    else echo "connection succeeded";
    ?>
    

I received error:

connection failed –No such file or directory

Than I have recompiled php with apache2 and mysql than the same code is throwing error:

connection failed –The server requested authentication method umknown to the client

mysql conf file is as below.

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

also at php.ini I have set

mysql.default_socket = /var/lib/mysql/mysql.sock

Please let me know how to proceed further.I am still getting the same error for wordpress.

Related posts

Leave a Reply

1 comment

  1. The first error

    No such file or directory

    is because of the path to mysqld.sock file is wrong. This probably has been fixed as you state later that another error you recieve is

    The server requested authentication method unknown to the client

    This error has been explained here on ServerFault

    MySQL introduced longer password hashes in (i think) version 4.1, and
    your server probably still uses them (check for 16 byte password
    hashes in your mysql user table). Newer versions use longer password
    hashes. Your server supports both, but your client (php) seems to
    support only new ones in this version (and on).

    If it’s possible, use the solution from the link in the first line,
    and set your password again with the new hash, but beware, if you’re
    using any other (old) clients which rely on old passwords,
    compatibility might break. Also try looking for old-password support
    for MySQL in PHP, but i’m not sure about it.