在MariaDB配置文件/etc/my.cnf  [mysqld]中加入skip-grant-tables一行:

[Richard@localhost ~]$ sudo vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables    #加入这一行
# Disabling symbolic-links is reco

重启服务:

[Richard@localhost ~]$ sudo systemctl restart mariadb.service

进入MariaDB修改root密码:

[Richard@localhost ~]$ mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 5.5.-MariaDB-wsrep MariaDB Server, wsrep_25..r4026 Copyright (c) , , Oracle, Monty Program Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 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]> show tables
-> ;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
rows in set (0.00 sec) MariaDB [mysql]> UPDATE user SET Password = password ( ' ) WHERE User = 'root' ;
Query OK, rows affected (0.03 sec)
Rows matched: Changed: Warnings: MariaDB [mysql]> flush privileges;
Query OK, rows affected (0.01 sec) MariaDB [mysql]> exit

重启服务即可登陆:

[Richard@localhost ~]$ sudo systemctl restart mariadb.service
[Richard@localhost ~]$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 5.5.-MariaDB-wsrep MariaDB Server, wsrep_25..r4026 Copyright (c) , , Oracle, Monty Program Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> exit

MariaDB忘记root密码的更多相关文章

  1. MySQL或MariaDB忘记root密码

    当我们忘记数据库密码时,我们可以通过如下来修改! 编辑配置文件(提前最好进行备份) 然后重启服务 systemctl restart mariadb 或者 systemctl restart mysq ...

  2. Linux下MySQL或MariaDB忘记root密码的解决方法

    1.vim /etc/my.cnf 2.在[mysqld]下添加一行skip-grant-tables,然后保存并退出. 3.重启mysql服务:service mysqld restart. 4.不 ...

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

    MariaDB(Mysql) root密码忘记的解决办法 1.首先先关闭mariadb数据库的服务 # 关闭mariadb服务命令(mysql的话命令就是将mariadb换成mysql) [root@ ...

  4. CentOS忘记mariadb/mysql root密码解决办法

    本文不再更新,可能存在内容过时的情况,实时更新请访问原地址:CentOS忘记mariadb/mysql root密码解决办法: 这里有两种方式实现修改mariadb root密码. mariadb版本 ...

  5. Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法

    一.停止并禁用firewalld [root@test ~]# systemctl stop firewalld [root@test ~]# systemctl disable firewalld ...

  6. MySQL 忘记root密码怎么办

    前言:记住如果忘记root密码,在启动MySQL的时候,跳过查询授权表就ok了. 对于RedHat 6 而言 (1)启动mysqld 进程时,为其使用:--skip-grant-tables --sk ...

  7. Mac上MySQL忘记root密码且没有权限的处理办法&workbench的一些tips (转)

    忘记Root密码肿么办 Mac上安装MySQL就不多说了,去mysql的官网上下载最新的mysql包以及workbench,先安装哪个影响都不大.如果你是第一次安装,在mysql安装完成之后,会弹出来 ...

  8. Linux忘记root密码怎么办?

    开篇前言:Linux系统的root账号是非常重要的一个账号,也是权限最大的一个账号,但是有时候忘了root密码怎么办?总不能重装系统吧,这个是下下策,其实Linux系统中,如果忘记了root账号密码, ...

  9. mysql忘记root密码解决办法

    最近项目中的数据库我放在了服务器上,但是今天突然不能用了,进入服务器查看,果然是数据库不能进去了,所以今天来分享一个mysql忘记root密码的解决方案: 1.让mysql不载入权限表,命令:mysq ...

随机推荐

  1. JQuery弹出窗口小插件ColorBox

    本文来自: Small_陌 http://www.cnblogs.com/wggmqj/archive/2011/11/04/2236263.html 今天在博客园看到一篇<ASP.NET MV ...

  2. linux 内核源代码分析 - 获取数组的大小

    #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 測试程序: #include<stdio.h> #include<stdlib. ...

  3. iOS开发--系统通讯录的访问与添加联系人

    公司项目有访问通讯录的需求,所以开始了探索之路.从开始的一无所知,到知识的渐渐清晰.这一切要感谢广大无私分享的 “coder”,注:我是尊称的语气! 苹果提供了访问系统通讯录的框架,以便开发者对系统通 ...

  4. 【C#】开发可以可视化操作的windows服务

    使用C#开发自定义windows服务是一件十分简单的事.那么什么时候,我们需要自己开发windows服务呢,就是当我们需要计算机定期或者一直执行我们开发的某些程序的时候.这里我以一个WCF的监听服务为 ...

  5. MapReduce详解

    1.mapreduce之shuffle http://blog.csdn.net/thomas0yang/article/details/8562910 2.彻底了解mapreduce核心Shuffl ...

  6. git撤销修改

    在Git中,删除也是一个修改操作,我们实战一下,先添加一个新文件test.txt到Git并且提交: $ git add test.txt $ git commit -m "add test. ...

  7. 删除数组中等于某个key的所有元素

    题目描述: 给定一个数组和一个值,在原地删除与值相同的数字,返回新数组的长度. 这道题目做暴力的想法就是,用一个指针从头到尾遍历,删除哪个元素就把后面的元素统一向前移动一个位置.但是这样的时间复杂度很 ...

  8. 多个不同的表合并到一个datatable中,repeater在绑定datatable

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI ...

  9. ConnectivityManager与检查网络连接的使用

    1.ConnectivityManager的作用 ConnectivityManager主要管理和网络管理相关的操作 TelephonyManager则管理和手机.运营商等的相关信息 WifiMana ...

  10. Python爬虫:常用浏览器的useragent

    1,为什么需要修改UserAgent 在写python网络爬虫程序的时候,经常需要修改UserAgent,有很多原因,罗列几个如下: 不同Agent下看到的内容不一样,比如,京东网站上的手机版网页和p ...