2

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

Error establishing a database connection

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.

3
  • The @ before mysql_connect is suppressing the error messages which may be helpful in figuring out what this is. Commented May 8, 2013 at 0:38
  • Try 127.0.0.1 instead of localhost Commented May 8, 2013 at 0:40
  • @JPR- I have already tried it. Problem persists. Commented May 8, 2013 at 4:40

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I am using Mysql5.5. I think above is not applicable for it.Please correct me if I am wrong.
@user2310989 Please also check the statement your client (php) seems to support only new ones in this version (and on). Try and run phpinfo() and confirm with your PHP installation.
php is running fine. if you want some specific detail than please let me know.
Problem solved-- I have below two users at mysql. When I have used test user instead of wpuser problem got resolved. | localhost | test | *676243218923905CF94CB52A3C9D3EB30CE8E20D | | localhost | wpuser | 43d23b2c1c6a90cc | +-----------+--------+------------------------------------------ Yes the solution suggested by hjpotter92 seems correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.