① # vim /etc/my.cnf
在[mysqld]下新增skip-grant-tables,然後儲存並退出
② 重啟mysql服務:service mysqld restart
③ 執行 mysql 命令進入資料庫,修改資料庫密碼
mysql> update mysql.user set password=password('新密碼') where user='root';
mysql> flush privileges;
④ 把/etc/my.cnf中的skip-grant-tables注釋掉,然後重啟mysql,
即:service mysqld restart
⑤ 下面就可以用root新的密碼登入了
[root@ops04 scripts]# vim /etc/my.cnf
[root@ops04 scripts]# service mysqld restart
restarting mysqld (via systemctl): [ ok ]
[root@ops04 scripts]#
[root@ops04 scripts]# mysql
welcome to the mariadb monitor. commands end with ; or \g.
your mariadb connection id is 4
server version: 10.1.22-mariadb mariadb server
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mariadb [(none)]>
mariadb [(none)]> set password=password('000000');
error 1290 (hy000): the mariadb server is running with the --skip-grant-tables option so it cannot execute this statement
mariadb [(none)]> update mysql.user set password=password('000000') where user='root';
query ok, 4 rows affected (0.00 sec)
rows matched: 4 changed: 4 warnings: 0
mariadb [(none)]> flush privileges;
query ok, 0 rows affected (0.00 sec)
mariadb [(none)]> exit
bye[root@ops04 scripts]# vim /etc/my.cnf
[root@ops04 scripts]# service mysqld restart
restarting mysqld (via systemctl): [ ok ]
[root@ops04 scripts]#
[root@ops04 scripts]# mysql -uroot -p000000
welcome to the mariadb monitor. commands end with ; or \g.
your mariadb connection id is 4
server version: 10.1.22-mariadb mariadb server
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mariadb [(none)]>
MySQl MySQL忘記密碼
1.修改mysql的登入設定 vi etc my.cnf2.重新啟動mysqld etc init.d mysqld restart service mysqld restart 3.登入並修改mysql的root密碼 mysql use mysql mysql update user set pa...
末 mysql mysql忘記root密碼
任何系統忘記密碼都是很蛋疼得,讓我不得不再次感嘆資料大爆發和沒有標準的網際網路環境真的讓人疼得厲害。這麼多公司,這麼多賬戶,而且對密碼的要求又大都不一樣,鬼知道我能記多少密碼,能記多長時間。前段時間在本地安裝mysql,死活是裝不上,缺東西,自己的源又配的有問題,各種包不好裝,記得以前裝過maria...
Centos7下mariadb忘記root密碼處理
1,停止mariadb服務systemctl stop mariadb 2,修改配置檔案 vim etc my.cnf 在 mysqld 下新增skip grant tables 意思是忽略密碼,儲存並退出 3,啟動mariadb systemctl start mariadb 4,修改密碼 mys...