Centos7 之 MariaDB(Mysql) root密码忘记的解决办法

摘要:
00grep--color=automariadb#检查端口是否也在使用中[root@node~]#netstat lntup|grep3306tcp 0 00.0.0:'or''''hrlp.Type''occurrencecurrentinputstatement.#更新密码MariaDB[(无)]>

MariaDB(Mysql) root密码忘记的解决办法

1.首先先关闭mariadb数据库的服务

# 关闭mariadb服务命令(mysql的话命令就是将mariadb换成mysql)

[root@node ~]# systemctl stop mariadb

# 通过进行查询服务或者通过端口查询服务还是否存在

[root@node ~]# ps aux|grep mariadb

root       6852  0.0  0.0 112704   964 pts/2    S+   23:19   0:00 grep --color=auto mariadb

[root@node ~]# netstat -lntup|grep 3306

2.修改配置

修改/etc/my.cnf文件,[mysqld]下添加 skip-grant-tables , 再启动mysql

Centos7 之 MariaDB(Mysql) root密码忘记的解决办法第1张

# 开启mariadb服务

[root@node ~]# systemctl start mariadb

# 查看服务已经开启

[root@node ~]# ps aux|grep mariadb

mysql      7104  1.1  5.6 972516 80672 ?        Sl   23:22   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock

root       7141  0.0  0.0 112704   964 pts/2    S+   23:22   0:00 grep --color=auto mariadb

# 查看端口也正在使用

[root@node ~]# netstat -lntup|grep 3306

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      7104/mysqld

3.进入数据库并更新密码

# 免密码可进入

root@node ~]# mysql -u root

Welcome to the MariaDB monitor.  Commands end with ; or g.

Your MariaDB connection id is 2

Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

# 更新密码

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

Query OK, 1 row affected (0.01 sec)

Rows matched: 4  Changed: 1  Warnings: 0

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit;

Bye

4.还原需要密码的配置

# 重新修改为原来配置并重启服务

[root@node ~]# vi /etc/my.cnf

[root@node ~]# systemctl restart mariadb

# 可以看到没有密码现在无法进入

[root@node ~]# mysql -u root

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

# 使用新密码进入mariadb数据库

[root@node ~]# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or g.

Your MariaDB connection id is 3

Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> 

同理此问题也可以解决其他linux版本的mariadb(mysql)密码忘记问题

免责声明:文章转载自《Centos7 之 MariaDB(Mysql) root密码忘记的解决办法》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇容器网络(一)docker容器网络驱动命令行下使用javah命令生成.h文件,出现“错误: 无法访问android.app.Activity 找不到android.app.Activity的类文件”的解决方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

FreeRTOS学习及移植笔记之二:在IAR和STM32F103VET上移植FreeRTOS

上一次,我们简单的测试了FreeRTOS的基于IAR EWARM v6.4和STM32F103VET6平台的Demo,对其有了一个基本认识。接下来我们开始自己移植FreeRTOS的过程。 1、创建一个“FreeRTOSTestProject”项目文件夹,并在其下创建FreeRTOS、Libraries、Project、User文件夹。 与无操作系统的项目...

Kratos 读源码笔记一(配置加载)

从入口文件看配置(初始化/加载/绑定/热加载) main.go //main.go 初始化配置 c := config.New( config.WithSource( file.NewSource(flagconf), //文件配置源 //也可以自己实现远程配置中心数据源 ), ) //加载配置数据 if err := c.L...

IDA破解最简单的登陆框

原创文章,转载请注明出处:http://www.cnblogs.com/justinzhang/       还记得当年本科的时候,一大群人围着一个国安的登陆框在哪儿破解。其实自己对安全方面的东西了解的非常的少,最近遇到一个非常牛逼的UML工具,可惜没有源代码、没有文档,在这种霸道的封杀之下,又点燃了学习反汇编&破解的热情。虽然这是一个非常非常简单...

Redmine windwon下载安装

Redmin地址:https://bitnami.com/stack/redmine/installer     redmin的admin用户忘记密码的方法;  就是 hashed_password 设置成 353e8061f2befecb6818ba0c034c632fb0bcae1b ,另外把salt 清空,密码就成了 password. sele...

安装mariadb

 安装mariadb有两个源,一个是阿里云的yum源,可能版本较低,软件包很小,功能很少 二个是mariadb官方的yum源,配置方式 在/etc/yum.repos.d目录下,建立一个repo文件就是yum仓库 #创建一个mariadb.repo文件,写入以下内容 [mariadb] name = MariaDB baseurl = http://yum...

电子签名实现的思路、困难及解决方案

        在办公自动化的流程中希望实现电子签名。        思路:            1、图片的存放:安全起见存放在库中为宜。最好不能被轻易下载。            2、使用的过程:显示一个密码框和“签名”按钮,输入密码并按下按钮后,如果正确,隐藏输入框和按钮,显示图片。            3、我的所有控件都是通过解析xml后动态生成...