MariaDB忘记root密码,修改root密码

原创 2017年08月29日 14:45:15

MariaDB忘记root密码,修改root密码
在MariaDB配置文件/etc/my.cnf的[mysqld]配置中加入一行:skip-grant-tables

# vi /etc/my.cnf

[mysqld]
port = 3306
socket = /data/sdv1/mydata/mariadb.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
skip-grant-tables    #加入这一行

修改配置文件

重启服务:

# /etc/init.d/mysqld restart

进入MariaDB修改root密码:

# mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.13-MariaDB Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation 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           |
+---------------------------+
| column_stats              |
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| gtid_slave_pos            |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| index_stats               |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| roles_mapping             |
| servers                   |
| slow_log                  |
| table_stats               |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
30 rows in set (0.00 sec)

MariaDB [mysql]> UPDATE user SET Password = password('123456') WHERE User = 'root'; 
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

MariaDB [mysql]> quit

将配置文件/etc/my.cnf [mysqld]中的skip-grant-tables注释掉,重启mysql服务即可:

# /etc/init.d/mysqld restart
# mysql -uroot -p

Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.13-MariaDB Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> quit

修改密码后重启

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cy309173854/article/details/77677933

MariaDB忘记root密码

原地址:http://www.cnblogs.com/Richard-xie/p/4205630.html 在MariaDB配置文件/etc/my.cnf  [mysqld]中加入skip-gr...
  • qq_21398167
  • qq_21398167
  • 2016-03-29 15:50:51
  • 2263

centos7 mariadb 设置root密码

修改root密码 1.以root身份在终端登陆,必须 2.输入 mysqladmin -u root -p password root 后面的 root 是要设置的密码 3.回车后出现 Ent...
  • cenguocheng
  • cenguocheng
  • 2014-11-19 15:29:20
  • 23120

mariaDB安装完成后设置root密码等初始化操作

修改root密码 1.以root身份在终端登陆(必须) 2.输入 mysqladmin -u root -p password ex 后面的 ex 是要设置的密码 3.回车后出现 Enter ...
  • julasuo1624
  • julasuo1624
  • 2017-09-24 15:25:27
  • 482

mariadb和mysql忘记密码怎么办

skip-grant-tables flush privileges
  • magicbreaker
  • magicbreaker
  • 2014-06-20 14:59:27
  • 4564

mysql/mariadb centos7 修改root用户密码及配置参数

一、修改用户密码,以root为例 1. 知道root密码,需要修改 a. 登入数据库来修改 # mysql -uroot -p /*输入密码进入*/ /*第一个方式:直接编辑数据库字段*/ Mari...
  • evandeng2009
  • evandeng2009
  • 2016-03-28 18:48:28
  • 11349

mariadb 重置密码

郁闷,ubuntu以命令行方式mariadb,安装过程中并未出现输入root用户的界面,安装完mariadb,不知道root用户密码,以root身份登陆报如下错误: david@david-pc:~...
  • liuwei0376
  • liuwei0376
  • 2017-01-10 11:51:02
  • 4731

Linux MariaDB 遗忘密码后重置密码

Linux MariaDB 遗忘密码后重置密码
  • yenai2008
  • yenai2008
  • 2017-01-06 16:15:24
  • 2217

虚拟机装了个ubuntu,忘记了密码?获取root用户?

1、可以在grub界面选择第二项修复,但没有grub可以参考: 1)重启ubuntu,随即长按shirft进入grub菜单; 2)选择recovery mode,按"e"键进入编辑...
  • yu704645129
  • yu704645129
  • 2018-03-15 17:29:44
  • 27

MariaDB忘记root密码,修改root密码

MariaDB忘记root密码,修改root密码
  • cy309173854
  • cy309173854
  • 2017-08-29 14:45:15
  • 1037

mariadb root忘记密码修改

1.修改maria的登录设置:  # vim /etc/my.cnf  在[mysqld]的段中加上一句:skip-grant-tables  例如:  [mysqld]  datadir=...
  • asd3705082
  • asd3705082
  • 2017-05-16 10:25:39
  • 170
收藏助手
不良信息举报
您举报文章:MariaDB忘记root密码,修改root密码
举报原因:
原因补充:

(最多只允许输入30个字)