1.确保系统中有依赖的libaio软件,使用如下命令[root@localhost ~]# yum -y install libaio
[root@localhost ~]# rpm -q libaio
libaio-0.3.109-13.el7.x86_64
2.使用wget命令下载mysql-5.7.24 软件包[root@localhost ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
3.将mysql安装包解压到指定目录,命令如下:[root@localhost ~]# tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
4.进入/usr/local目录[root@localhost ~]# cd /usr/local/
5.为mysql安装目录创建软链接[root@localhost local]# ln -s mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
6.添加mysql用户和组和[root@localhost local]# useradd -M -s /sbin/nologin mysql
7.修改当前目录拥有者为新建的mysql用户,命令如下:[root@localhost mysql]# chown -R mysql:mysql ./
8.初始化mysql数据库(建立默认的库和表),命令如下:[root@localhost mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
将随机生成的登录密码记录下来: e9iIEYBa9t!f
9.开启mysqld服务,命令如下[root@localhost mysql]# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid
[root@localhost mysql]# ./support-files/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/mariadb.log'.
. SUCCESS!
[root@localhost mysql]# netstat -lnpt |grep :3306
tcp6 0 0 :::3306 :::* LISTEN 2220/mysqld
10.将mysqd服务添加到系统服务中,命令如下[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# ls -l /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10576 12月 7 16:12 /etc/init.d/mysqld
[root@localhost mysql]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
11.使用随机密码登录mysql数据库,命令如下[root@localhost mysql]# ./bin/mysql -u root -p
等待系统提示,输入随机密码,即可登录
12.设置mysql管理用户root的新密码[root@localhost mysql]# ./bin/mysqladmin -u root -p'e9iIEYBa9t!f' password '123456'
13.将mysql命令添加到系统命令执行路径中,便于使用。[root@localhost mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[root@localhost mysql]# cd
[root@localhost ~]# mysql -u root -p123456