【MariaDB】centos7 忘记了 MariaDB root密码
centos7 MariaDB 忘记了MariaDB root密码的解决办法
1.停掉mariaDB
systemctl stop mariadb.service
2.KILL掉系统里的MySQL进程;
ps -ef | grep mariadb #查询进程PID
kill 进程PID
3.用以下命令启动MySQL,以不检查权限的方式启动;
mysqld_safe -skip-grant-tables &
或是 修改/etc/my.cnf文件,在[mysqld]下添加 skip-grant-tables ,
再启动mysql
3. 然后用空密码方式使用root用户登录 MySQL;
mysql -u root
4. 修改root用户的密码;
MariaDB [(none)]> update mysql.user set Password=password(‘123456’) where User=‘root’;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
- 改完密码别忘记删除配置文件中的 skip-grant-tables
- 重新启动MySQL,就可以使用新密码登录
7.用root登录下数据库验证下数据。
8.修改表信息
MariaDB [cheungssh]> select * from auth_user;
MariaDB [cheungssh]> update auth_user set username=‘mh’ where id=‘1’;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0