欢迎投稿

今日深度:

腾讯云CentOS系统安装的MariaDB忘记密码,centosmariadb

腾讯云CentOS系统安装的MariaDB忘记密码,centosmariadb


MariaDB配置文件/etc/my.cnf加入skip-grant-tables一行。

#vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables    #add this line by joule
# Disabling symbolic-links is reco
......

重启MariaDB服务:

systemctl restart mariadb.service

进入MariaDB修改root密码:

# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.02 sec)

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                      |
| wrbpqd                    |
| ysiium32                  |
+---------------------------+
26 rows in set (0.00 sec)

MariaDB [mysql]> select user from user where user='root';
+------+
| user |
+------+
| root |
| root |
| root |
| root |
+------+
4 rows in set (0.00 sec)

MariaDB [mysql]> UPDATE user SET Password= password('******') WHERE User= 'root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

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

MariaDB [mysql]> exit;
Bye


去掉或者注释置文件/etc/my.cnf加入skip-grant-tables

重启服务

systemctl restart mariadb.service
使用新密码进行登录

mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)




www.htsjk.Com true http://www.htsjk.com/mariadb/36508.html NewsArticle 腾讯云CentOS系统安装的MariaDB忘记密码,centosmariadb MariaDB配置文件/etc/my.cnf加入 skip -grant- tables 一行。 #vi /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockskip-grant-tables #add this li...
相关文章
    暂无相关文章
评论暂时关闭