[转]Mariadb的root密码忘记后的解决方法
环境背景:CentOS 7.2
一、编辑/usr/lib/systemd/system/mariadb.service 文件,在Service段中添加 |
1
2
3
4
5
6
7
8
9
10
11
12
|
[Service] Type=simple User=mysql Group=mysql User=mysql Group=mysql ExecStartPre= /usr/libexec/mariadb-prepare-db-dir %n # Note: we set --basedir to prevent probes that might trigger SELinux alarms, # per bug #547485 #在Server段中的ExecStart出添加如下 ExecStart= /usr/bin/mysqld_safe --basedir= /usr --skip-grant-tables --skip-networking |
二、键入systemctl daemon-reload使其立即生效 |
1
|
[root@node1 ~] # systemctl daemon-reload |
三、重新启动mariadb服务并使用mysql联入 |
1
2
3
4
5
6
7
8
9
10
11
|
[root@node1 ~] # systemctl restart mariadb.service [root@node1 ~] # mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> |
四、更改root用户的密码 |
1
2
3
4
5
6
|
MariaDB [(none)]> UPDATE mysql.user SET Password=PASSWORD( 'xiaoshui' ) WHERE user= 'root' and host= 'localhost' ; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0 MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) |
五、退出并关闭mariadb服务并把/usr/lib/systemd/system/mariadb.service文件中刚刚添加的那两行移除 |
1
2
|
ExecStart= /usr/bin/mysqld_safe --basedir= /usr ExecStartPost= /usr/libexec/mariadb-wait-ready $MAINPID |
六、启动mariadb服务,并使用新设置的密码连接 |
1
2
3
4
5
6
7
8
9
10
11
|
[root@node1 ~] # mysql -u root -h localhost -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> |
参考:http://dashui.blog.51cto.com/11254923/1877042
[转]Mariadb的root密码忘记后的解决方法的更多相关文章
- MySQL root密码忘记后更优雅的解决方法
MySQL root密码忘记后更优雅的解决方法 https://www.jb51.net/article/143453.htm /usr/bin/mysqld_safe --defaults-file ...
- Centos7 之 MariaDB(Mysql) root密码忘记的解决办法
MariaDB(Mysql) root密码忘记的解决办法 1.首先先关闭mariadb数据库的服务 # 关闭mariadb服务命令(mysql的话命令就是将mariadb换成mysql) [root@ ...
- root密码忘记后如何修改
方法一: 1.在DOS窗口下输入net stop mysql5 或 net stop mysql 2.开一个DOS窗口,这个需要切换到mysql的bin目录.一般在bin目录里面创建一个批处理1.ba ...
- vmvare centos 7.0 root密码忘记后重置及总结
今天遇到了一个比较尴尬的事情,我centos 7.0的虚拟机密码忘了.....里面还有我配置好的环境呢.于是我就上网上搜索各种方法,最后经我验证下面这个方法比较靠谱: 使用光盘修复Centos: ht ...
- mysql5.7中root密码忘记后修改密码
一.更改my.cnf配置文件 1.用命令编辑/etc/my.cnf配置文件,即:vim /etc/my.cnf 或者 vi /etc/my.cnf 2.在[mysqld]下添加skip-grant-t ...
- CentOS忘记mariadb/mysql root密码解决办法
本文不再更新,可能存在内容过时的情况,实时更新请访问原地址:CentOS忘记mariadb/mysql root密码解决办法: 这里有两种方式实现修改mariadb root密码. mariadb版本 ...
- Ubuntu root 密码忘记-恢复
@Ubuntu root 密码忘记-恢复 2012-04-27 11:09:22 方法一: 如果用户具有sudo权限,那么直接可以运行如下命令: #sudo su root #passwd #更改密码 ...
- centos7 mariadb 设置root密码
centos7 mariadb 设置root密码 修改root密码1.以root身份在终端登陆,必须2.输入 mysqladmin -u root -p password root后面的 root ...
- [转载]Ubuntu 14.04中root 密码忘记解决方法
Ubuntu 14.04中root 密码忘记解决方法 方法一: 如果用户具有sudo权限,那么直接可以运行如下命令: #sudo su root #passwd #更改密码 或者直接运行sudo ...
随机推荐
- SharePoint 多行文本字段设置默认值
前言 最近有这样一个需求,创建一个表单,里面有多行文本字段,但是要求内容默认带一个表格,这样用户新建项目的时候,就可以直接填表格了. 好吧,这样的需求我们可以通过JavaScript实现. 1.默认的 ...
- Java全栈程序员之04:Ubuntu下安装MySQL、注册服务及Navcat
在安装MySQL之前,我们先来介绍一下Ubuntu下软件的安装方式.首先回顾下,我们安装JDK,使用的是后缀名为tar.gz的安装包.安装idea,使用的是tar.gz:那有没有别的安装方式呢? 1. ...
- ln: creating symbolic link XXXXXX : Operation not supported
ln: creating symbolic link XXXXXX : Operation not supported 转自:https://blog.csdn.net/z444_579/articl ...
- 【T04】开发并使用应用程序框架
1.TCP/IP应用程序分为 TCP服务器 TCP客户端 UDP服务器 UDP客户端 2.构建框架库是比较简单的一件事,主要就是对socket编程.
- Windows下libjpeg-trubo-1.5.3编译(VS2015)
简述 https://libjpeg-turbo.org/的网站上是有已经编译好的版本下载的,但是VC下是使用的VC10.0编译的.虽然在VC14.0下也能用,但是我还是需要编译一个VC14.0版本的 ...
- gcc下inline的一个问题
今天发现一个问题,与inline有关,也与编译时候是不是优化有关. 大概问题可以用下面的代码来描述: 先写一个libtest1,代码如下 libtest1.h #ifndef LIBTEST_H #d ...
- EasyUI tabs update 正确用法
来源:http://ewoyaofei.blog.163.com/blog/static/343562612012617111734974/ 一直以为 tabs update 是 easyui 的 b ...
- System Monitor for Mac(系统监控工具)破解版安装
1.软件简介 System Monitor 是 macOS 系统上的一款非常实用的 Mac 系统工具,System Monitor for mac 是一款六合一应用,您可以同时获得 CPU.RA ...
- Communications link failure due to underlying exception异常处理(转)
最近的一个项目在Hibernate使用C3P0的连接池,数据库为Mysql.开发测试没有问题,在运行中每个一段长的空闲时间就出现异常: java 代码 org.hibernate.exception. ...
- [svc]linux iptables实战
参考: http://blog.51yip.com/linux/1404.html 链和表 参考: https://aliang.org/Linux/iptables.html 配置 作为服务器 用途 ...