修改 MySQL 配置文件以跳过密码登录

# vim /etc/my.cnf 


重启 MySQL 服务

# systemctl restart mysqld.service


[root@cvm-3ibcdh728a225 html]# mysql -u root 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

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

mysql> 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
mysql> update user set authentication_string='your-new-passwd' where user='root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges ;
Query OK, 0 rows affected (0.02 sec)

mysql> quit


# vim /etc/my.cnf 

重启 MySQL

# systemctl restart mysqld.service


— end —

This entry was posted in 默认分类 and tagged . Bookmark the permalink.