在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 2
Server version: 5.5.40-MariaDB-wsrep MariaDB Server, wsrep_25.11.r4026Copyright (c) 2000, 2014, 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 -ADatabase 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                      |
+---------------------------+
24 rows in set (0.00 sec)MariaDB [mysql]> UPDATE user SET Password = password ( '123456 ) WHERE User = 'root' ;
Query OK, 4 rows affected (0.03 sec)
Rows matched: 4  Changed: 4  Warnings: 0MariaDB [mysql]> flush privileges;
Query OK, 0 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 2
Server version: 5.5.40-MariaDB-wsrep MariaDB Server, wsrep_25.11.r4026Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> exit

转载于:https://www.cnblogs.com/Richard-xie/p/4205630.html

MariaDB忘记root密码相关推荐

  1. mariadb忘记root密码,重设密码

    系统:linux deepin 20.8 / mariadb 10.3.36 1.关闭服务 systemctl stop mariadb.service 2.查找maraiadb的配置文件,我的为50 ...

  2. mysql忘了root密码_mysql忘记root密码怎么办

    产品型号:Thinkpad E15 系统版本:centos8 软件版本:mysql 5.7 mysql忘记root密码怎么办 启动MySQL服务的时候跳过权限表认证. 停止数据库 [root@xueg ...

  3. debian linux忘记密码,debian ubuntu linux 忘记root密码的重置方法

    在前一章,讲了在 redhat/CentOS 等系统中,忘记 root 密码的重置方法,是修改 grub 里的 kernel 那一行,使其进入单用户,然后修改密码,可以这种方法,在 ubuntu 以及 ...

  4. mysql忘记root密码及修改密码

    方法1: 用SET PASSWORD命令  首先登录MySQL.  格式:mysql> set password for 用户名@localhost = password('新密码');  例子 ...

  5. MySQL忘记root密码不重启mysqld的方法

    MySQL忘记root密码不重启mysqld的方法 1.首先得有一个可以拥有修改权限的mysql数据库账号,当前的mysql实例账号(较低权限的账号,比如可以修改zabbix数据库)或者其他相同版本实 ...

  6. 【Linux】14.ubuntu忘记root密码、用户密码输入次数过多锁住的问题

    忘记root密码.用户密码输入次数过多锁住的问题 1.忘记root密码 参考 https://www.linuxidc.com/Linux/2016-05/131256.htm (1) 忘了root密 ...

  7. ubuntu16.04:成功解决ubuntu16.04 忘记root密码

    ubuntu16.04:成功解决ubuntu16.04 忘记root密码 解决方法 1.reboot,按住Esc键或者shift键,出现如下界面,选中第二个选项 2.箭头指到第二个选项,此时按下e键, ...

  8. Linux下使用MySQL——忘记root密码及修改MySQL默认编码

    概述: 本博客不再对MySQL的语法进行讲解和说明,想了解或熟悉的朋友请自行百度或Google学习.本博客主要是针对MySQL除语法之外的总结,希望能够也能帮助到你. 1.CentOS6.x下MySQ ...

  9. win10中的ubuntu子系统忘记root密码如何修改

    win10中的ubuntu子系统忘记root密码如何修改 请看好标题,是子系统不是虚拟机,root密码忘记了,怎么找回或者修改,请赐教. Sign in to vote 非常感谢repl,本来已经不报 ...

  10. AIX忘记root密码后,重设密码步骤

    忘记root密码后,重设root密码步骤: 1. 插入系统启动光盘(就是AIX 安装光盘的 CD 1),重启系统. 2. 在系统启动界面出现时,按1键,进入sms menu模式. 3. 选择7(Sel ...

最新文章

  1. 博弈论经典算法(一)——对抗搜索与Alpha-Beta剪枝
  2. css 加随机数 引用_在CSS中生成随机数
  3. mysql 查数据 default无效_导入mysql数据的时候提示Field * doesn't have a default value解决方法...
  4. C#LeetCode刷题之#404-左叶子之和​​​​​​​​​​​​​​(Sum of Left Leaves)
  5. C语言编程笔记丨一种很酷的 C 语言技巧
  6. 【转】MS SQL Sever 远程安装导入数据演示(图)
  7. JS计算GridView里的TextBox
  8. 想要导航提示页_如何优化网站导航呢?
  9. java使用Redis3--完整模板类
  10. 无法导入reg:指定的文件不是注册脚本——兼了解文本格式问题
  11. 用于自动驾驶的实时联合目标检测和语义分割网络
  12. Rational Rose使用说明
  13. Jmeter读取CSV文件读取不到解决方法
  14. 为什么一个概念会非常难懂呢?人是如何理解的呢?
  15. 阿宇相机智能双光配置
  16. 以太网 VLAN简介、MAC地址表与VLAN的关联内容
  17. 文案写作之销售文案写作技巧
  18. BOS开发工具的使用心得
  19. 无聊的程序员教你如何使用十几行代码练就单身20年的手速(文末彩蛋)
  20. 高效办公,这5款工具你不该错过

热门文章

  1. PCB走线载流能力-揭秘一
  2. 用 HTML5 和 Javascript 仿制一个水果忍者网页版! (直接浏览器在线玩+源代码下载)...
  3. 如何在一个项目中兼容Wepy和Taro?
  4. 王者荣耀英雄铭文;出装
  5. luogu P2765 魔术球问题 (最小路径覆盖)
  6. apache配置Options详解
  7. setInterval()和setTimeout()
  8. Java 输出通过 InetAddress 获得的 IP 地址数组
  9. (转载) MTK之NVRAM研究[三]
  10. python3.7升级pip_完美解决python3.7 pip升级 拒绝访问问题