2024 桐庐半程马拉松
00:00:00
时间
0.00
距离(公里)
--:--
配速
--
步频
--
心率 (bpm)
--
配速
步频
|
share-image
ESC

mariadb 重置密码

如果忘记数据库密码,可以做下面的操作进行重置

停止数据库

root@Techs-Public:~# /etc/init.d/mariadb start

重置密码

root@Techs-Public:~# mysqld_safe --skip-grant-tables &
[2] 21207
root@Techs-Public:~# 170719 13:39:43 mysqld_safe Logging to '/usr/local/mariadb/var/mariadb.err'.
170719 13:39:43 mysqld_safe A mysqld process already exists
mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.23-MariaDB Source distribution

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)]> use mysql;
Database changed
MariaDB [mysql]>

MariaDB [mysql]> update user set password=PASSWORD('upyun@#techs') where user="root";
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

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

MariaDB [mysql]>quit

启动数据库

root@Techs-Public:~# /etc/init.d/mariadb start
[ ok ] Starting mariadb (via systemctl): mariadb.service.
root@Techs-Public:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.23-MariaDB Source distribution

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)]>
文章作者:阿文
文章链接: https://www.awen.me/post/223599102.html
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 阿文的博客
本文于 2017-07-19 发布,已超过半年(3116天),请注意甄别内容是否已过期。