2012-07-31 2 views
2

내 컴퓨터에서 실행중인 Wordpress를 내 컴퓨터 (localhost)에서 터널링되는 원격 mysql 데이터베이스에 연결하려고합니다. 워드 프레스의 wp-config.php 파일에서 mysql CLI 클라이언트강제로 워드 프로세서가 TCP를 통해 데이터베이스에 연결

$ mysql --protocol=TCP -P 10000 -h localhost -u username -p'password' db_name 

Reading table information for completion of table and column names 
You can turn off this feature to get a quicker startup with -A 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 93438893 
Server version: 5.5.8-log Source distribution 

Copyright (c) 2000, 2011, 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 databases; 
+-----------------------------------+ 
| Database       | 
+-----------------------------------+ 
| information_schema    | 
| db_name       | 
+-----------------------------------+ 
2 rows in set (1.38 sec) 

에 다음과 같은 매개 변수를 제공하여 데이터베이스 연결 작업, 나는 다음과 같은 값을 시도 :

define('DB_NAME', 'db_name'); 
define('DB_USER', 'username'); 
define('DB_PASSWORD', 'password'); 
define('DB_HOST', 'localhost'); 
define('DB_PORT', 10000); 

이 &를 작동하지 않는 다음과 같은 오류가 발생합니다 :

Warning: include(/home/gaurish/Dropbox/code/projects/blog/wp-content/advanced-cache.php): failed to open stream: No such file or directory in /home/gaurish/Dropbox/code/projects/blog/wp-settings.php on line 62 
Warning: include(): Failed opening '/home/gaurish/Dropbox/code/projects/blog/wp-content/advanced-cache.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/gaurish/Dropbox/code/projects/blog/wp-settings.php on line 62 
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/gaurish/Dropbox/code/projects/blog/wp-includes/wp-db.php on line 1038 

상기 에러의 마지막 라인 (Can't connect to local MySQL server through socket)는 왜 t를 범 그는 WordPress가 유닉스 소켓을 통해 연결하려고 할 때 연결이 실패합니다.

이제는 데이터베이스에 연결할 수 있도록하기 위해 어떤 매개 변수를 설정해야합니까? mysql CLI 클라이언트?

답변

3

wp-config.php에 다음 설정을 사용하여 연결할 수있었습니다.

define('DB_NAME', 'db_name'); 
define('DB_USER', 'username'); 
define('DB_PASSWORD', 'password'); 
define('DB_HOST', '127.0.0.1:10000'); 
define('DB_PORT', 10000); 

데이터베이스 연결이 성공 :)

3

유닉스 소켓 대신 TCP를 통해 연결하려면 localhost에서 127.0.0.1으로 호스트를 변경하십시오.

define('DB_HOST', '127.0.0.1'); // forces TCP 
+0

이 을 시도했다 그러나 그것은 너무 오류 발생 : '경고 :로 mysql_connect()를'127.0.0.1 '(111)에서 MySQL 서버에 연결할 수 없습니다 /home/gaurish/Dropbox/code/projects/blog/wp-includes/wp-db.php on line 1038' 더 많은 아이디어가 있습니까? – CuriousMind

+1

오류 111은 액세스가 거부되었음을 의미합니다. TCP를 통해 연결하도록 허용 된 사용자를 추가 했습니까? – drew010

+0

http://stackoverflow.com/questions/1420839/cant-connect-to-mysql-server-error-111 – drew010

0

확인이 아웃 :

http://chxo.com/be2/20040511_5667.html 아주 잘 모든 것을 설명은 (내가 그것을 할 필요로 할 때 내가 간 곳은, 요점은이 말씀을 다시 반복 보지 않았다).

관련 문제