TA的每日心情 | 开心 2023-8-9 11:05 |
---|
|
1.修改/etc/my.cnf,添加skip-grant-tables
- [mysql]
- default-character-set=utf8
- [mysqld]
- skip-name-resolve
- port = 3306
- basedir=/usr/local/mysql
- datadir=/app/mysql/data
- max_connections=200
- character-set-server=utf8
- lower_case_table_names=1
- default-storage-engine=INNODB
- skip-grant-tables
复制代码 2.启动mysql
systemctl start mysql
3.无密码登录mysql,-p提示输入密码后,直接回车进入
- [root@vm1 etc]# mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 7
- Server version: 8.0.27 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
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> flush privileges;
- Query OK, 0 rows affected (0.04 sec)
复制代码 4.修改密码
- mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'mysql';
- Query OK, 0 rows affected (0.00 sec)
- mysql>
- mysql>
- mysql>
- mysql> flush privileges;
- Query OK, 0 rows affected (0.01 sec)
复制代码 5.关闭数据库
systemctl stop mysql
6.去掉my.cnf中的skip-grant-tables
7.启动数据库,正常密码登录
|
|