xampp修改mysql默认密码

一:xampp修改mysql默认空密码

前言:

刚接触xampp这个软件,一直都在用PHPstudy,想修改个mysql密码,PHP好连接,没想到一查,什么乱七八糟的都有,还有收费的???,自己查了资料,感觉这个方式挺通俗易懂的
1、登录phpmyadmin

image-20230511094112171

2、选择mysql表

image-20230511094221339

3、在sql这里执行SQL语句

image-20230511093722958

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
这是MySQL数据库的修改密码语句,将root用户的密码修改为root。

2、
注意,如果您正在使用MySQL 8.0或更高版本,则应该使用以下语句:
	ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
	这是因为MySQL 8.0中已经废弃了SET PASSWORD语句。
4、刷新页面提示登录不进去

image-20230511094528662

1)解决方法
1、找到phpMyadmin的配置文件,默认路径是C:\xampp\phpMyAdmin,下的config.inc.php,修改代码登录密码


2、原始代码和修改后的代码
*原始代码密码为空*
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

*修改后的代码,密码修改成了root*
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';
5、再次刷新页面登录

登录成功

image-20230511095033985

猜你喜欢

转载自blog.csdn.net/a5200059/article/details/130615268
今日推荐