[转]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=simpleUser=mysqlGroup=mysqlUser=mysqlGroup=mysqlExecStartPre=/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 ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 2Server version: 5.5.44-MariaDB MariaDB ServerCopyright (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: 0MariaDB [(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 -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 4Server version: 5.5.44-MariaDB MariaDB ServerCopyright (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 ...
随机推荐
- Knockout.Js官网学习(Mapping插件)
前言 Knockout设计成允许你使用任何JavaScript对象作为view model.必须view model的一些属性是observable的,你可以使用KO绑定他们到你的UI元素上,当这些o ...
- [Android Pro] 关于Android 7.0无法进行https抓包的问题
cp from : https://www.cnblogs.com/wytings/p/6954293.html 在App进行数据请求的时候,如果每次都打印log去判断是一件很不“人性化”的操作行为 ...
- DateTables的服务器分页
function InitTable() { var table = $('#tbl_users').DataTable(); if ($.fn.dataTable.isDataTable('#tbl ...
- 学习率设置&&训练模型之loss曲线滑动平均
tensorflow中学习率.过拟合.滑动平均的学习 tensorflow中常用学习率更新策略 TensorFlow学习--学习率衰减/learning rate decay 分段常数衰减 分段常数衰 ...
- JAVA 自定义注解在自动化测试中的使用
在UI自动化测试中,相信很多人都喜欢用所谓的PO模式,其中的P,也就是page的意思,于是乎,在脚本里,或者在其它的page里,会要new很多的page对象,这样很麻烦,前面我们也讲到了注解的使用,很 ...
- 如何部署hadoop集群
假设我们有三台服务器,他们的角色我们做如下划分: 10.96.21.120 master 10.96.21.119 slave1 10.96.21.121 slave2 接下来我们按照这个配置来部署h ...
- SqlServer 2008的tempdb数据文件大小暴增处理
tempdb数据文件暴增,导致服务器磁盘空间被耗尽! 1.查看tempdb的使用分配情况 use tempdb go SELECT top 10 t1.session_id, t1.internal_ ...
- java中使用队列:java.util.Queue(转)
队列是一种特殊的线性表,是运算受到限制的一种线性表,只允许在表的一端进行插入,而在另一端进行删除元素的线性表.队尾(rear)是允许插入的一端.队头(front)是允许删除的一端.空队列是不含元素的空 ...
- RabbitMQ三种Exchange模式(fanout,direct,topic)的性能比较(转)
RabbitMQ中,所有生产者提交的消息都由Exchange来接受,然后Exchange按照特定的策略转发到Queue进行存储 RabbitMQ提供了四种Exchange:fanout,direct, ...
- ambari安装 QA
1.在安装时 出现Public key for ambari-server-2.4.2.0-136.x86_64.rpm is not installed 安装ambari报错 在安装HST服务时也报 ...