How to change root password of phpmyadmin in WAMP?

痴心易碎 提交于 2019-12-08 03:04:25

问题


I opened mysql console and wrote the following :

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

Now when I open phpmyadmin, it says "Access denied for user 'root'@'localhost' (using password: NO)"

I was trying to set a password for root and I read it somewhere that we change root password from console itself, unlike previous versions where we had to alter the config files.

Any detailed tutorial on changing root password to secure a database?

I'm new to all this. Thank you.


回答1:


Once you have changed the root password you need to tell phpMyAdmin what the new password is as by default the root password is held in the c:\wamp\apps\phpmyadmin4.1.14\phpmyadmin.conf file.

/*
 * First server
 */
$i++;
/* Authentication type */
$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'] = 'YOUR_NEW_PASSWORD';        <--change
/* 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'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = false;              <--change

A better solution in my opinion is to change this file so that phpMyAdmin throws a login screen so you can enter/test new accounts as well as just root

So I would change c:\wamp\apps\phpmyadmin4.1.14\phpmyadmin.conf to

/*
 * First server
 */
$i++;
/* Authentication type */
$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'] = '';
/* 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;

Now you will get a login screen like this




回答2:


To change the default mysql root password on xampp, type the following on mysql console:

UPDATE mysql.user SET Password=PASSWORD('som3P@Ss') WHERE User='root'; 
FLUSH PRIVILEGES;

then open [XAMPP Installation Path] /phpmyadmin/config.inc.php and modify it to:

$cfg['Servers'][$i]['password'] = 'som3P@Ss';
$cfg['Servers'][$i]['AllowNoPassword'] = false;


来源:https://stackoverflow.com/questions/31357665/how-to-change-root-password-of-phpmyadmin-in-wamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!