在phpMyAdmin中更改MySQL root密码

时间:2014-05-28 09:28:48

标签: php mysql phpmyadmin

我在窗口设置wamp服务器。然后,我使用cmd的MySQL root密码。因此,当我访问phpMyAdmin网站时,Access denied出现(phpMyAdmin的默认用户为root,密码为blank/empty)。那么,我怎么能用新的root密码更改phpMyAdmin中的config变量。

我已在互联网上搜索解决方案,有人建议我在config.inc.php添加一些代码:

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'Changed';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = false;

但是,它似乎不起作用。感谢。

6 个答案:

答案 0 :(得分:21)

解释用于解决问题的视频描述

更改root(Mysql帐户)密码后。访问phpmyadmin页面将被拒绝,因为phpMyAdmin使用root /''(空白)作为默认用户名/密码。要解决此问题,您需要重新配置phpmyadmin。编辑文件夹%wamp%\ apps \ phpmyadmin4.1.14中的文件config.inc.php(不在%wamp%中)

$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'changed';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

如果您有多个数据库服务器,请添加" i ++"如上所述提交并继续添加新配置

答案 1 :(得分:13)

您可以通过直接登录数据库来更改mysql root密码(mysql -h your_host -u root)然后运行

SET PASSWORD FOR root@localhost = PASSWORD('yourpassword');

答案 2 :(得分:6)

0)去phpmyadmin不要选择任何db
1)点击"权限"。您将在MySQL的权限表中看到所有用户 2)检查用户" root"其Host值为localhost,然后单击" Edit Privileges"图标。
3)在"更改密码"字段,单击"密码"并输入新密码 4)重新输入密码进行确认。然后点击" Go"应用设置。

答案 3 :(得分:0)

您可以使用此命令

 mysql> UPDATE mysql.user SET Password=PASSWORD('Your new Password') WHERE User='root';

检查链接  http://www.kirupa.com/forum/showthread.php?279644-How-to-reset-password-in-WAMP-server  http://www.phpmytutor.com/blogs/2012/08/27/change-mysql-root-password-in-wamp-server/

在phpMyAdmin安装目录下找到你的config.inc.php文件,并更新看起来像的行    这样:

$cfg['Servers'][$i]['password']      = 'password';

......对此:

 $cfg['Servers'][$i]['password']      = 'newpassword';

答案 4 :(得分:0)

像这样改变它对我有用。希望能帮助到你。 冷杉我做了

$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'changed';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

然后我改变了这样......

$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

答案 5 :(得分:0)

我必须做两个步骤:

  • 按照Tiep Phan解决方案...编辑config.inc.php文件...

  • 按照Mahmoud Zalt解决方案...在phpmyadmin中更改密码