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.

4

1 回答 1

1

第一个错误

没有这样的文件或目录

是因为mysqld.sock文件路径不对。这可能已经修复,因为您稍后会指出您收到的另一个错误是

服务器请求客户端未知的身份验证方法

此错误已在 ServerFault 上进行了解释

MySQL 在(我认为)4.1 版中引入了更长的密码哈希,您的服务器可能仍在使用它们(检查 mysql 用户表中的 16 字节密码哈希)。较新的版本使用较长的密码哈希。您的服务器同时支持两者,但您的客户端 (php) 似乎只支持此版本(及更高版本)中的新客户端。

如果可能,请使用第一行链接中的解决方案,并使用新哈希再次设置密码,但请注意,如果您使用的任何其他(旧)客户端依赖于旧密码,兼容性可能会中断。还尝试在 PHP 中寻找对 MySQL 的旧密码支持,但我不确定。

于 2013-05-08T01:05:39.943 回答