如何修改Xampp中MySQL的root密码?

MySQL 的“root”用户默认状态是没有密码的,所以在 PHP 中您可以使用 mysql_connect("localhost","root","") 来连接 MySQL 服务器;

如果您想为 MySQL 中的“root”用户设置密码(例如:本机MySQL密码为 123456),请在控制台中使用“mysqladmin”命令。例如:

d:\PHP\xampp\mysql\bin\mysqladmin.exe  -u  root  password  123456

另外,如果是先前有秘密,则修改命令为:

d:\PHP\xampp\mysql\bin\mysqladmin.exe -u root -p password 123456

回车后提示你输入密码,输入“旧密码”即可。

请注意,更改 root 的密码之后,不要忘记更改 PHPMyAdmin 中的相关信息。在 ...xamppphpmyadmin 下搜索“config.inc.php”并编辑下面几行:

$cfg['Servers'][$i]['user'] = 'root'; // MySQL SuperUser
$cfg['Servers'][$i]['auth_type'] = 'http'; // HTTP MySQL authentification

从今往后,需要正确输入“root”的密码才能启动 PHPMyAdmin。

重启MySQL服务后新密码生效!

参考:

扫描二维码关注公众号,回复: 1147012 查看本文章
01 <?php
02  
03 $cfg['blowfish_secret'] = 'a8b7_snsgou.com_c6d';
04  
05 /* Servers configuration */
06 $i = 0;
07  
08 /* Server: localhost [1] */
09 $i++;
10 $cfg['Servers'][$i]['verbose'] = 'localhost';
11 $cfg['Servers'][$i]['host'] = 'localhost';
12 $cfg['Servers'][$i]['port'] = '';
13 $cfg['Servers'][$i]['socket'] = '';
14 $cfg['Servers'][$i]['connect_type'] = 'tcp';
15 $cfg['Servers'][$i]['extension'] = 'mysqli';
16 $cfg['Servers'][$i]['auth_type'] = 'cookie';
17 $cfg['Servers'][$i]['AllowNoPassword'] = false;

猜你喜欢

转载自taogekary.iteye.com/blog/2187050
今日推荐