数据库设置密码后无法访问phpMyAdmin
在我为 MySQL 设置密码后,phpMyAdmin 拒绝访问数据库并显示以下错误:
MySQL 说:
1045 - 用户“root”@“localhost”访问被拒绝(使用密码:NO)
我已经用谷歌搜索并试图弄乱配置文件,我尝试了一切,但无法想出解决方案。我什至浏览了Stack Overflow之前的问题,但那里的答案也没有改变情况。
这是我的 config.inc.php 文件:
<?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysqli';
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'root';
/* 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['AllowAnywhereRecoding'] = true;
$cfg['DefaultCharset'] = 'utf-8';
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman/5.1/en';
$cfg['MySQLManualType'] = 'searchable';
?>
After I set password to MySQL, phpMyAdmin is denying access to the database and is showing the following error:
MySQL said:
1045 - Access denied for user 'root'@'localhost' (using password: NO)
I have googled it and tried to mess with the config file, I tried everything, but couldn't come up with a solution. I even went through the previous questions of Stack Overflow, but the answers there also didn't change the situation.
Here is my config.inc.php
file:
<?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysqli';
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'root';
/* 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['AllowAnywhereRecoding'] = true;
$cfg['DefaultCharset'] = 'utf-8';
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman/5.1/en';
$cfg['MySQLManualType'] = 'searchable';
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下是您应该为 phpmyadmin config.inc.php 文件编写的代码:
如果您遇到主机配置问题,您应该使用:
如果这不起作用,这里有另一个不需要任何编码的解决方法:
Here's the code you should have for the phpmyadmin config.inc.php file:
If you are having issues w the host configuration, you should use:
If that doesn't work, here's another work-around that doesn't require any coding:
1)进入目录C:\xampp\phpMyAdmin,打开文件config.inc.php
2)然后找到第21行,将其更改为(123456是我的mysql root密码)
3)然后找到第34行,并将其更改 4)保存
文件。然后尝试刷新mysql页面。这在大多数情况下都必须有效..
1) Go to the directory C:\xampp\phpMyAdmin and open the file config.inc.php
2) Then find the line 21 and change it to (123456 is my mysql root password)
3) Then find the line 34 and change it to
4) Save the file. Then try to refresh the mysql page. This must work in most cases..
你也可以尝试这个..
将您的密码字段留空
You Can Try This Too..
Leave Your Password Field Blank
另一种选择是,在 config.inc.php 中,将 auth_type 更改为 'cookie'
或者,您也可以将 auth_type 设置为 'http'
无论使用哪种方法,下次登录 phpmyadmin 时,它都会提示您输入用户名和密码。
来源 = https://wiki.phpmyadmin.net/pma/Auth_types
Another option is, inside config.inc.php, change the auth_type to 'cookie'
Or, you can also set auth_type to 'http'
With either method, next time you login to phpmyadmin, it should prompt you for a username and password.
Source = https://wiki.phpmyadmin.net/pma/Auth_types