用户工具

站点工具


zh:notes:centos_mysql_pwd

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
zh:notes:centos_mysql_pwd [2022/10/22 20:42]
pzczxs [修改MySQL的登录设置]
zh:notes:centos_mysql_pwd [2023/03/23 07:42] (当前版本)
pzczxs [Start mysql Service]
行 1: 行 1:
 ====== Reset the Password of MySQL in the CentOS ====== ====== Reset the Password of MySQL in the CentOS ======
-===== Stop mysql =====+===== Stop mysql Service ​=====
 <code bash> <code bash>
-> systemctl stop mysqld+> systemctl stop mysqld.service
 </​code>​ </​code>​
  
-===== Set the MySQL environment ​Option =====+===== Set the Environment ​Option =====
 <code bash> <code bash>
 > systemctl set-environment MYSQLD_OPTS="​--skip-grant-tables"​ > systemctl set-environment MYSQLD_OPTS="​--skip-grant-tables"​
 </​code>​ </​code>​
  
-===== Start mysql =====+===== Login as root without Password ​=====
 <code bash> <code bash>
 +> systemctl start mysqld.service
 > mysql -uroot > mysql -uroot
 </​code>​ </​code>​
行 23: 行 24:
 </​code>​ </​code>​
  
-===== Stop mysql =====+===== Stop mysql Service and Unset the Environment Option ​=====
 <code bash> <code bash>
-> systemctl stop mysqld+> systemctl stop mysqld.service 
 +> systemctl unset-environment MYSQLD_OPTS
 </​code>​ </​code>​
  
-===== Unset the MySQL Environment Option ​=====+===== Start mysql Service ​=====
 <code bash> <code bash>
-> systemctl ​unset-environment MYSQLD_OPTS+> systemctl ​start mysqld.service
 </​code>​ </​code>​
  
-===== Start mysql =====+===== Login with New Password ​=====
 <code bash> <code bash>
-systemctl start mysqld +> mysql -uroot -p
-</​code>​ +
- +
- +
-===== 重新启动mysqld ===== +
-<​code>​ +
-# service mysqld restart +
-</​code>​ +
- +
-===== 登录并修改MySQL的root密码 ===== +
-<​code>​ +
-mysql  +
-mysql> USE mysql ;  +
-mysql> UPDATE user SET Password = password ( '​new-password'​ ) WHERE User = '​root'​ ;  +
-mysql> flush privileges ;  +
-mysql> quit +
-</​code>​ +
- +
-===== 将MySQL的登录设置修改回来 =====  +
-<​code>​ +
-# vim /etc/my.cnf  +
-</​code>​ +
-将刚才在[mysqld]的段中加上的skip-grant-tables删除  +
-保存并且退出vim +
- +
-===== 重新启动mysqld =====  +
-<​code>​ +
-# service mysqld restart ​+
 </​code>​ </​code>​
  
 ~~DISCUSSION:​closed~~ ~~DISCUSSION:​closed~~
  
zh/notes/centos_mysql_pwd.1666442562.txt.gz · 最后更改: 2022/10/22 20:42 由 pzczxs