Mysql 5.5 重置root密碼
如果忘記了root密碼,可以透過下面的流程來重置密碼:
注:需要重啟資料庫
由於不知道root的密碼,不能透過常規的方式來關閉資料庫
透過殺掉程式的方式來強制關閉資料庫
[root@localhost ~]# ps -ef|grep mysql
root 26764 55613 0 Apr04 pts/2 00:00:00 /bin/sh ./mysqld_safe --defaults-file=/etc/my.cnf
mysql 27174 26764 0 Apr04 pts/2 00:01:04 /data/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/data --datadir=/var/lib/mysql --plugin-dir=/data/lib/plugin --user=mysql --log-error=/log/err.log --open-files-limit=10240 --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root 27192 55613 0 Apr04 pts/2 00:00:00 ./mysql -usystem -px xxxxxxxxx mysql
root 34544 18985 0 12:11 pts/3 00:00:00 /data/bin/mysql -ufire -px xxxxxxxxx
root 37683 13290 0 19:32 pts/0 00:00:00 grep mysql
[root@localhost ~]# kill `cat /var/run/mysqld/mysqld.pid`
[root@localhost bin]# ./mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables --skip-networking&
[1] 38252
更改管理員使用者密碼
[root@localhost bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.48-log production environment
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user();
+--------+
| user() |
+--------+
| root@ |
+--------+
1 row in set (0.00 sec)
mysql> update mysql.user set password=password('System#2013') where user='system';
Query OK, 0 rows affected (0.15 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.19 sec)
關閉資料庫並重新啟動資料庫
[root@localhost bin]# ./mysqladmin -usystem shutdown -p
Enter password:
160405 19:48:22 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[1]+ Done ./mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables --skip-networking
[root@localhost bin]# ./mysqld_safe --defaults-file=/etc/my.cnf &
[1] 38903
[root@localhost bin]# 160405 20:07:43 mysqld_safe Logging to '/log/err.log'.
160405 20:07:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
注:需要重啟資料庫
由於不知道root的密碼,不能透過常規的方式來關閉資料庫
透過殺掉程式的方式來強制關閉資料庫
[root@localhost ~]# ps -ef|grep mysql
root 26764 55613 0 Apr04 pts/2 00:00:00 /bin/sh ./mysqld_safe --defaults-file=/etc/my.cnf
mysql 27174 26764 0 Apr04 pts/2 00:01:04 /data/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/data --datadir=/var/lib/mysql --plugin-dir=/data/lib/plugin --user=mysql --log-error=/log/err.log --open-files-limit=10240 --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root 27192 55613 0 Apr04 pts/2 00:00:00 ./mysql -usystem -px xxxxxxxxx mysql
root 34544 18985 0 12:11 pts/3 00:00:00 /data/bin/mysql -ufire -px xxxxxxxxx
root 37683 13290 0 19:32 pts/0 00:00:00 grep mysql
[root@localhost ~]# kill `cat /var/run/mysqld/mysqld.pid`
以下面方式啟動資料庫,忽略授權驗證和禁止網路客戶端連線
[root@localhost bin]# ./mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables --skip-networking&
[1] 38252
更改管理員使用者密碼
[root@localhost bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.48-log production environment
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user();
+--------+
| user() |
+--------+
| root@ |
+--------+
1 row in set (0.00 sec)
mysql> update mysql.user set password=password('System#2013') where user='system';
Query OK, 0 rows affected (0.15 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.19 sec)
[root@localhost bin]# ./mysqladmin -usystem shutdown -p
Enter password:
160405 19:48:22 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[1]+ Done ./mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables --skip-networking
[root@localhost bin]# ./mysqld_safe --defaults-file=/etc/my.cnf &
[1] 38903
[root@localhost bin]# 160405 20:07:43 mysqld_safe Logging to '/log/err.log'.
160405 20:07:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2076005/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 重置Root密碼MySql密碼
- MySQL 8.0 重置 root 密碼MySql密碼
- mysql5.7重置root密碼MySql密碼
- 在Linux中,如何重置 mysql root 密碼?LinuxMySql密碼
- Ubuntu重置root密碼Ubuntu密碼
- mysql 8 如何重置 root 使用者密碼MySql密碼
- MySql5.5忘記root密碼怎麼辦MySql密碼
- CentOS 7.5 重置 root 密碼CentOS密碼
- 記一次MySql重置root密碼無效MySql密碼
- win10 mysql8.0.12 忘記root密碼如何重置密碼Win10MySql密碼
- rocky9如何重置root密碼密碼
- centos7的root密碼重置CentOS密碼
- linux破解root登入密碼,並重置Linux密碼
- Tool-Gitlab-重置root賬戶密碼Gitlab密碼
- MySQL 8 下重置密碼MySql密碼
- RHEL7重置root管理員密碼密碼
- MySQL 資料庫重置密碼MySql資料庫密碼
- mac版MySQL重置初始密碼MacMySql密碼
- Mac下MySQL密碼重置方法MacMySql密碼
- mysql 5.7忘記root密碼MySql密碼
- 修改Mysql root密碼的方法MySql密碼
- ESXI 6.5利用Centos7重置root密碼CentOS密碼
- 在 5 分鐘內重置丟失的 root 密碼密碼
- 破解 MariaDB5.5 資料庫的 root 登入密碼資料庫密碼
- MySQL 8.0.15忘記密碼重置方法MySql密碼
- mysql 8.0.11 以上版本修改root密碼MySql密碼
- MySQL的Root使用者密碼MySql密碼
- mysql忘了root密碼怎麼辦MySql密碼
- MYSQL5.7 ROOT密碼修改教程MySql密碼
- Linux系統Centos7修改或重置root密碼教程。LinuxCentOS密碼
- ubuntu系統下mysql重置密碼和修改密碼操作UbuntuMySql密碼
- MySQL8.0 忘記 root 密碼下如何修改密碼MySql密碼
- 如何在Mac上重置MySQL根密碼MacMySql密碼
- 09 MySQL系統賬戶密碼重置MySql密碼
- Ubuntu 如何重設 MySQL 的 root 密碼UbuntuMySql密碼
- Ubuntu MySQL5.7設定root密碼UbuntuMySql密碼
- Linux伺服器---mysql忘記root密碼Linux伺服器MySql密碼
- mysql如何修改root使用者的密碼MySql密碼
- 【VMware vCenter】在不重啟的情況下重置vCenter Server的root密碼。Server密碼