1、查看一下有没有libaio这个软件包
[root@localhost ~]# rpm -q libaio
libaio-0.3.109-12.el7.x86_64
2、把mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz rz进来
3、解压:[root@localhost ~]# tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin games lib libexec sbin src
etc include lib64 mysql-5.7.24-linux-glibc2.12-x86_64 share
4、因为它的名字特别长所以给它改个名叫mysql:
[root@localhost local]# mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
5、添加mysql用户和组
[root@localhost local]# useradd -M -s /sbin/nologin mysql
6、修改当前目录拥有者为新建的mysql用户:
[root@localhost local]# chown -R mysql:mysql /usr/local/mysql/
7、初始化mysql数据库:
[root@localhost local]# /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --initialize
会生成一个密码
8、修改mysql配置文件
[root@localhost local]# vim /etc/my.cnf
修改内容
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid
9、将mysql服务添加到系统服务中
[root@localhost local]# cp mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost local]# chmod +x /etc/init.d/mysqld // 添加执行权限
[root@localhost local]# chkconfig --add mysqld //添加到系统服务里
[root@localhost local]# systemctl start mysqld // 起服务
10、登录mysql
[root@localhost local]# mysql -uroot -p'?Wrd+:8bXR!r'
bash: mysql: 未找到命令...
进不去的话创建一个软链接到/bin下
[root@localhost local]# ln -s /usr/local/mysql/bin/mysql /bin/
[root@localhost local]# mysql -uroot -p'?Wrd+:8bXR!r'
11、修改mysql的密码
[root@localhost local]# ln -sf /usr/local/mysql/bin/* /bin/ //把/bin下的所有都做软链接
[root@localhost local]# mysqladmin -uroot -p'?Wrd+:8bXR!r' password 123 //修改密码
[root@localhost local]# mysql -uroot -p'123' //登录
11、破密码
首先确保关闭mysql
[root@localhost ~]# systemctl stop mysqld
[root@localhost ~]# ps aux | grep mysqld
root 40578 0.0 0.0 112724 984 pts/1 R+ 09:54 0:00 grep --colr=auto mysql-5.7d
[root@localhost ~]# mysqld_safe --skip-grant-tables &
[root@localhost ~]# mysql
进入就不用密码了,类似单用户