Mysql

phpMyAdmin:#1045 - 使用者 ‘root’@’localhost’ 的訪問被拒絕(使用密碼:是)。

  • September 1, 2017

我在 phpMyAdmin 中遇到著名的 #1045 錯誤:使用者’root’@’localhost’ 的訪問被拒絕(使用密碼:YES)。

這是我的 /etc/phpmyadmin/config.inc.php:

/**
* Server(s) configuration
*/
$i = 0;
// The $cfg['Servers'] array starts with $cfg['Servers'][1].  Do not use $cfg['Servers'][0].
// You can disable a server config entry by setting host to ''.
$i++;

/* Authentication type */
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
//$cfg['Servers'][$i]['host'] = 'localhost';
//$cfg['Servers'][$i]['connect_type'] = 'tcp';
//$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
//$cfg['Servers'][$i]['extension'] = 'mysql';
/* Optional: User for advanced features */
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Optional: Advanced phpMyAdmin features */
// $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['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

/*
* End of servers configuration
*/

/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

任何想法?

你意識到所有的配置行都被註釋掉了嗎?您需要取消註釋並填寫這些欄位才能發生任何事情。我認為包括這個就足夠了(假設您希望它提示您輸入使用者名/密碼):

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

執行以下命令

$ mysqladmin -u root 密碼 abcd

並將配置文件中的密碼用作“abcd”

或用“abcd”替換您的密碼

引用自:https://serverfault.com/questions/161967