xampp changes mysql default password

1: xampp changes the default empty password of mysql

Foreword:

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

image-20230511094112171

2. Select the mysql table

image-20230511094221339

3. Execute SQL statements here in 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. Refresh the page and prompt that you cannot log in.

image-20230511094528662

1) Solution
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. Refresh the page again to log in

login successful

image-20230511095033985

Guess you like

Origin blog.csdn.net/a5200059/article/details/130615268