数据库二进制安装
实验步骤一:把需要的数据库包传到主机
实验步骤二:安装依赖包
实验步骤三:创建mysql用户并且验证
实验步骤四:解压mysql软件包并且做软链接
实验步骤五:修改mysql的属组和属主
实验步骤六:创建数据存放目录并且修改属主和属组
实验步骤七:添加环境变量并且使之生效
实验步骤八:初始化数据库
实验步骤九:修改配置文件
实验步骤十:配置服务启动脚本
实验步骤十一:启动服务,并且修改数据库密码
实验步骤十二:验证数据库密码是否修改成功
破解密码步骤
步骤详解
-
修改配置文件,在配置文件中加入下行
skip-grant-tables
-
重启数据库 service mysqld restart
-
登录数据库(此时不需要密码)
-
修改密码
-
把配置文件还原(即把之前添加的文件加上#注释掉即可)
-
重启数据库
破解步骤演示
① 在配置文件中加入以下内容
[root@localhost ~]# vi /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
skip-grant-tables //添加此行表示跳过授权表,跳过密码验证直接进入数据库
②重启
[root@localhost ~]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
③登录数据库,不需密码可直接登录
[root@localhost ~]# mysql -uroot -p //登录数据库
Enter password: //输入密码直接跳过
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
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>
④修改密码
mysql> alter user 'root'@'localhost' identified by 'centos'; //修改密码为centos
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; //刷新权限
Query OK, 0 rows affected (0.00 sec)
⑤把配置文件还原
[root@localhost ~]# vi /etc/my.cnf //还原配置文件,把之前添加内容删除即可
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
⑥重启数据库验证
[root@localhost ~]# service mysqld restart //重启数据库
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@localhost ~]# mysql -uroot -p'centos' //新密码验证
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 2
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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)