时间:2020-06-13来源:www.pcxitongcheng.com作者:电脑系统城
#vim /etc/my.cnf(注:windows下修改的是my.ini)
很多老铁,在开始时设置了 MySQL 的密码,后来一段时间没有用 MySQL之后,密码忘了~ QAQ,请别急,现在有以下方法解决密码忘了的情况。
1.首先我们需要跳过 MySQL 的密码认证:
(1)进入 /etc/my.cnf 文件
| 1 | [root@localhost ~]# vim /etc/my.cnf |
(2)在 [mysqld] 的下面添加 " skip-grant-tables " 用来跳过 MySQL 登录时候的密码验证:
[mysqld] skip-grant-tables
2.重启下 MySQL :
[root@localhost lib]# systemctl restart mysqld.service
3.进入 MySQL 中使用命令对密码进行修改:
//使用名字叫 mysql(或者自己创建过) 数据库
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
//这里我把 账号 root 密码设置为 root
mysql> update mysql.user set authentication_string=password('root') where user='root' ;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
// 刷新
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
4.验证是否对密码重新设置成功:
[root@localhost /]# mysql -uroot -proot //注意:这里一般直接输入密码登录,可能会不安全 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.30 MySQL Community Server (GPL) Copyright (c) 2000, 2020, 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>
2024-07-18
Centos 7 二进制安装配置 MariaDB数据库2024-07-18
Centos7默认firewalld防火墙使用命令大全2024-07-07
四种执行python系统命令的方法常用权限linux系统内有档案有三种身份 u:拥有者 g:群组 o:其他人这些身份对于文档常用的有下面权限:r:读权限,用户可以读取文档的内容,如用cat,more查看w:写权限,用户可以编辑文档x...
2024-07-07
然而,如果我们遵循通常的 WordPress 最佳实践,这些安全问题可以避免。在本篇中,我们会向你展示如何使用 WPSeku,一个 Linux 中的 WordPress 漏洞扫描器,它可以被用来找出你安装...
2024-07-03