programing

WordPress와 데이터베이스 연결 설정 오류 디버그 방법

oldcodes 2023. 10. 6. 21:58
반응형

WordPress와 데이터베이스 연결 설정 오류 디버그 방법

다음과 같이 워드프레스 사이트에 접속하려고 할 때localhost, 알겠습니다.

데이터베이스 연결을 설정하는 중 오류가 발생했습니다.

이 문제를 디버그하려면 어떻게 해야 합니까?로그는 어디서 볼 수 있습니까?

사용자와 함께 MySQL에 로그인할 수 있습니다.wordpressuser위에localhost. 나는 정확한 보조금을 가지고 있는 것 같습니다.wordpressuser데이터베이스 상에서wordpress:

root@myhost# mysql -hlocalhost -uwordpressuser -pmypassword 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 109
Server version: 5.5.37-0+wheezy1 (Debian)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show grants for wordpressuser@localhost;
+----------------------------------------------------------------------------------------------------------------------+
| Grants for wordpressuser@localhost                                                                                   |
+----------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wordpressuser'@'localhost' IDENTIFIED BY PASSWORD '*somepassword' |
| GRANT ALL PRIVILEGES ON `wordpress`.* TO 'wordpressuser'@'localhost'                                                 |
+----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

하지만 달리다 보면mysqlaccess, 알겠습니다.

root@myhost# mysqlaccess localhost wordpressuser wordpress -pmypassword
mysqlaccess Version 2.06, 20 Dec 2000
By RUG-AIV, by Yves Carlier (Yves.Carlier@rug.ac.be)
Changes by Steve Harvey (sgh@vex.net)
This software comes with ABSOLUTELY NO WARRANTY.
Password for MySQL user wordpressuser: 

Sorry,
An error occured when trying to connect to the database
with the grant-tables:
* Maybe YOU do not have READ-access to this database?
* If you used the -U option, you may have supplied an invalid username?
  for the superuser?
* If you used the -U option, it may be possible you have to supply
  a superuser-password to, with the -P option?
* If you used the -P option, you may have supplied an invalid password?

wget localhost연결이 거부된 상태에서 실패:

user@myhost:~$ wget localhost
--2014-06-08 01:11:29--  http://localhost/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2014-06-08 01:11:29 ERROR 500: Internal Server Error.

나의wp-config올바른 자격 증명(DB_NAME, DB_USER, DB_PASSER, DB_HOST)이 있는 것 같습니다.

이 문제를 디버그하려면 어떻게 해야 합니까?

저는 이 문제를 다음과 같이 일시적으로 해결할 수 있었습니다.

php가 mysql 데이터베이스에 접속하는 장소를 찾으려다, 나는 a.

grep Ri db.user /var/www

그것을 발견하다 보면

/var/www/wp-includes/load.php

데이터베이스를 다음 행에 만듭니다.

$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );

저는 값을 열심히 코딩해 보았습니다.DB_USER.DB_PASSWORD,DB_NAME,DB_HOST, 이제 사이트가 로컬 호스트에 로드됩니다.다음에 정의된 값 사이에 불일치가 있는 것이 분명합니다.wp-config.php, 그리고 실제로 전달되는 사람들은new wpdb(...), 아직 더 이상 추적할 수는 없지만요

의견 중 하나에서 제안된 것과 달리:

  1. 이것은 웹 서버의 문제가 아니었습니다.이제 로컬 호스트 내에서 또는 외부에서 사이트가 정상적으로 작동합니다.

  2. 명령어wget localhost이제 올바르게 작동합니다.다운로드합니다.index.htmlword press setup 페이지가 포함되어 있습니다.

언급URL : https://stackoverflow.com/questions/24103221/how-to-debug-error-establishing-a-database-connection-with-wordpress

반응형