오늘 Redhat Linux에 wordpress 를 설치할 일이 있어서 mysql database 를 생성하고 wp-config.php 에 DB 정보를 넣고 Browser 에서 연결을 하니 다음과 같은 에러 메시지가 나오며

설치가 진행이 되지 않았다.


"Error establishing a database connection' 


httpd나 php 의 로그도 남지 않아 원인파악이 힘들어서 다음과 같은 test code 를 만들어서 error message 를 확인해 보았다.


PDO db 연결 설정

<?php
$hostIn     = 'localhost';
$dbIn       = 'wordpress';
$userIn     = 'wordpress';
$passwordIn = 'wordP071';
try {
    $MySQLDataBaseLink = new PDO(
                    "mysql:host=" . $hostIn . ";dbname=" . $dbIn, $userIn, $passwordIn);
    $MySQLDataBaseLink->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo 'Yippee - good connection' . "\r\n";
} catch(PDOException $e) {
    echo '<h3>Catch Connect Error--->>> ' . $e->getMessage() . '</h3>' . "\r\n";
    return false;
} //End Try Catch
?>
PHP

php test.php 로 실행하자 다음과 같은 에러가 콘솔에 떨어졌다.

Warning: PDO::__construct(): The server requested authentication method unknown to the client [mysql_old_password] in /var/www/html/wordpress/db.php on line 11

The server requested authentication method umknown to the client

확인해 보니 /etc/my.cnf 에 old-passwords = 1 이 있어서 발생했고(어떻게 들어갔는지는 모름) 저 내용을 제거하고 MySQL 을 재구동하자 정상 동작했다.


wordpress에 적용된 DB wrapper 이 기능이 부족해서 그런지 에러 로그가 전혀 남지 않아 처리가 좀 곤란했는데 다음에 또 설치시 문제가 생기면 저 테스트 코드를 재활용해야 겠다


참고