MariaDB修改root密码

MariaDB数据库忘记密码怎么办呢?

不用怕,用以下几条命令帮你搞定


1.停止数据库服务

[root@tengine ~]# service mysql stop

Starting MySQL. SUCCESS!

2.启动mysqld服务,加上--skip-grant-tables选项

[root@tengine ~]# service mysql start --skip-grant-tables

Shutting down MySQL.. SUCCESS!

3.进入数据库

[root@tengine ~]# mysql -uroot

175923588.jpg

4.更新root数据库密码

MariaDB [(none)]> 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

MariaDB [mysql]> update user set Password=password('123456') where User='root';

Query OK, 4 rows affected (0.04 sec)

Rows matched: 4 Changed: 4 Warnings: 0

注:123456为你自己的新密码

MariaDB [mysql]> flush privileges;

Query OK, 0 rows affected (0.00 sec)


MariaDB [mysql]>

180155380.jpg

经过上面的命令把数据库的root密码更改为123456咯。


你可能感兴趣的:(mariaDB,mariaDB,忘记密码,root密码,数据库服务)