使用用户账号密码登录MySQL
[root@localhost ~]# mysql -uroot -p
切换到存储用户名和密码的数据库
[mysql]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
修改密码,使用password()函数进行加密,实际上就是执行sql语句来更新指定用户的密码
[mysql]> update user set password=password('新密码') where user='要更新密码的用户名';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
刷新用户权限列表
[mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出mysql登陆
[mysql]> quit
Bye
重启mysql或者mariadb服务
[root@localhost ~]# service mysqld restart(重启mysql)
ps: 使用root用户
评论区