在 XAMPP 中更改 MySQL 根密码

Change MySQL Root Password in XAMPP

我 XAMPP 在我的 Windows 10 机器上工作。似乎 PHPMyADmin 仅在数据库没有密码的情况下才有效。我真的更愿意为根数据库帐户设置密码。

我进入了 XAMPP 控制面板 -> 用户帐户 -> 为 root 帐户编辑​​权限。

当我输入新密码并点击 'go' 时,我刷新了页面,它说无法连接。有没有什么方法可以在不破坏 PHPMyAdmin 的情况下为 XAMPP 设置根数据库密码?

打开C:\xampp\phpMyAdmin文件夹,然后打开config.inc.php:

然后,像这样更改行:

$cfg['Servers'][$i]['auth_type'] = 'config'; //change this to cookie from config
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';

收件人:

$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';

然后使用空白密码登录,然后转到 SQL 选项卡,然后 运行 这个:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'