2013-08-02 148 views
1

基本上,我的config.inc.php文件有問題。但是我會描述事件的順序,以防我弄壞了其他我不知道的東西。無法通過phpMyAdmin訪問數據庫

我已經在phpMyAdmin中建立了一個數據庫,我在本地主機上使用了幾個月。它與XAMPP一起安裝。根據XAMPP/xamppfiles/phpMyAdmin/README文件,它是phpMyAdmin Version 3.5.7

有一段時間,我已經離開['controluser'] = 'pma' and ['controluserpass'] = 'pmapass'。幾個星期前,我改變這些值,但是,顯然創造了一個問題,因爲phpMyAdmin的開始向我展示

"Connection for controluser as defined in your configuration failed"

警告所有的時間。儘管如此,我仍然能夠做我需要做的一切;所以我一直在使用我的數據庫。

昨天我不得不殺了一個已經超過8個小時的查詢。之後,phpMyAdmin似乎正在加載其他數據庫和表格有點慢。所以我打開了XAMPP並按下了MySQL的停止按鈕。很明顯,這個按鈕不再爲我停止MySQL。圖標簡單地旋轉和旋轉,彷彿在思考。所以,截至今天,我一直在停止並直接從終端啓動MySQL,而不是通過XAMPP Control界面。

由於我看到了controluser的警告,我決定重寫config.inc.php文件來解決在那裏出現的任何問題。不幸的是,我只會讓事情變得更糟。現在我根本無法訪問我的數據庫。

我已經花了5個小時研究如何設置我的config.inc.php文件,但我仍然無法訪問我的數據庫。在過去,我使用'config'選項設置了它,並且從不必輸入密碼。理想情況下,我寧願擁有密碼安全性。但在這個階段,我很樂意重新獲得我的數據庫。

現在,localhost/phpmyadmin轉到登錄頁面,默認情況下爲「用戶名」輸入了「root」。但我似乎無法登錄。根據我對config.inc.php所作的調整,有時「用戶名」默認爲亂碼;其他時間出現錯誤消息而不是登錄名。不管是什麼我輸入密碼進入,phpMyAdmin的也不會接受:

2002 Cannot log in to the MySQL server

其他時候,我得到這個錯誤:

2002 - Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2) The server is not responding (or the local server's socket is not correctly configured).

我已經試過

之間來回切換
$cfg['Servers'][$i]['auth_type'] = 'cookie' 

$cfg['Servers'][$i]['auth_type'] = 'config' 

$cfg['Servers'][$i]['connect_type'] = 'tcp' 

$cfg['Servers'][$i]['connect_type'] = 'socket' 

$cfg['Servers'][$i]['AllowNoPassword'] = false 

$cfg['Servers'][$i]['AllowNoPassword'] = true 

和之間之間

$cfg['Servers'][$i]['host'] = 'localhost' 

$cfg['Servers'][$i]['host'] = '127.0.0.1' 

似乎沒有任何允許訪問我的數據庫。

目前,我得到的登錄畫面,並將該錯誤:

2002 Cannot log in to the MySQL server

我應該怎麼改?下面是我的config.inc.php文件:

<?php 

$cfg['blowfish_secret'] = '89x7a3f'; 

$i = 0; 

$i++; 

$cfg['Servers'][$i]['auth_type'] = 'cookie'; 

$cfg['Servers'][$i]['host'] = 'localhost'; 

$cfg['Servers'][$i]['AllowRoot'] = true; 

$cfg['Servers'][$i]['connect_type'] = 'tcp'; 

$cfg['Servers'][$i]['compress'] = true; 

$cfg['Servers'][$i]['extension'] = 'mysqli'; 
$cfg['Servers'][$i]['AllowNoPassword'] = false; 

$cfg['Servers'][$i]['user'] = 'root'; 
$cfg['Servers'][$i]['password'] = 'pass'; 

// $cfg['Servers'][$i]['controlhost'] = ''; 

$cfg['Servers'][$i]['controluser'] = 'pma'; 
$cfg['Servers'][$i]['controlpass'] = 'pmapass'; 

$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; 
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; 
$cfg['Servers'][$i]['relation'] = 'pma_relation'; 
$cfg['Servers'][$i]['table_info'] = 'pma_table_info'; 
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; 
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; 
$cfg['Servers'][$i]['column_info'] = 'pma_column_info'; 
$cfg['Servers'][$i]['history'] = 'pma_history'; 

//$cfg['DefaultConnectionCollation'] = 'utf8_general_ci'; 

$cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs'; 
$cfg['Servers'][$i]['tracking'] = 'pma_tracking'; 
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords'; 
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig'; 
$cfg['Servers'][$i]['recent'] = 'pma_recent'; 

// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf'; 

$cfg['UploadDir'] = ''; 
$cfg['SaveDir'] = ''; 

$cfg['DefaultLang'] = 'en'; 


?> 
+0

我一直在不斷改變config.inc.php中的各種設置,但沒有運氣。但是我注意到在這個錯誤消息指示的目錄中沒有mysql.sock文件:「#2002 - 無法通過套接字連接到本地MySQL服務器」/ Applications/XAMPP/xamppfiles/var/mysql/mysql。 sock'(2) 服務器沒有響應(或本地服務器的套接字未正確配置)。「 StackOverflow.com上的其他人報告了類似的問題,但沒有人提出過答案:http://stackoverflow.com/questions/5530215/mysql-problem-no-mysql-sock – user2647547

+0

如果我嘗試通過XAMPP關閉MySQL控制並等待足夠長時間,我收到此錯誤消息:「關閉MySQL .................................. ............錯誤!「 – user2647547

+0

在終端/應用程序/ xampp/xamppfiles/bin/mysqladmin版本 我得到 錯誤:'無法通過套接字連接到本地MySQL服務器'/ Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'(2)' 檢查mysqld是否正在運行,並且套接字:'/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'存在!與此同時,localhost/phpmyadmin將我的所有數據庫和表格帶到屏幕上。在重新啓動我的電腦之前,它進入了登錄屏幕。現在它跳過了,即使我什麼都沒改變。但phpMyAdmin本身並不連接到數據庫或表。 – user2647547

回答

4

如果你只需要訪問數據庫,你知道你的登錄憑據,請嘗試使用adminer:

http://www.adminer.org/

這只是一個單一的PHP文件,你放入你的web服務器,並沒有phpMyAdmin的安全漏洞的歷史。我們用MySQL和Postgres上的adminer替換了所有的phpMyAdmin安裝,效果很好。

+0

謝謝,但我喜歡phpMyAdmin。我只需要恢復訪問權限。 – user2647547

+0

如果phpMyAdmin是唯一被破壞的東西,那就重新安裝它。 – ChunkyBaconPlz

+0

我不確定整個phpMyAdmin是否損壞。這可能只是config.inc.php文件的一個問題。一切工作都很好,昨天已經好幾個月了。我寧願不必重複安裝軟件,因爲這就像使用大錘推動拇指大拇指一樣。另外,它可能會導致意外的數據丟失。 – user2647547

0

經過2天的嘗試,以及任何人曾經在網上發佈過的東西,我解決了這個問題。這並不意味着我知道問題是如何發生的,或者如何防止它再次發生,或者解決方案爲什麼起作用,或者它意味着什麼。但這是我發現的,以下是我如何解決這個問題。

我注意到,當我輸入了以下到終端

locate mysql.sock 

我得到了一個令人驚訝的結果:

/private/var/mysql/mysql.sock 

我期待了的mysql.sock不同的文件路徑。其他人在線通過在兩個文件路徑之間使用符號鏈接解決了類似的問題。

ln -s /private/var/mysql/mysql.sock /Applications/xampp/xamppfiles/var/mysql/mysql.sock 

現在我能編輯我的config.inc.php文件沒有問題:在我的情況下,整個問題與在終端一個命令解決。另外,我現在可以通過XAMPP Control停止MySQL。最重要的是,我可以通過phpMyAdmin再次訪問我的數據庫。

所以我的問題是99%解決。但有一點讓我感到困惑:雖然在「關係視圖」中,我曾經看到2列 - 一列用於外鍵,另一列用於表格內部的鍵。現在我只看到外鍵。所以我想知道config.inc.php中需要改變什麼來重新獲得另一個選項,我相信我至少在一個表中使用了這個選項。