1.下载MySQL安装包

MySQL下载地址为:点此下载 挑选你需要的 MySQL Community Server 版本及对应的平台。

2.检测系统是否安装MySQL

$ rpm -qa |grep mysql
mysql-libs-5.1.73-5.el6_6.x86_64
$ yum -y remove mysql-libs* #删除旧的安装包

3.安装MySQL

1)rpm 方式安装:

$ rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm
$ rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm
$ rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm
$ rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm
$ /etc/init.d/mysql start  #启动mysql
$grep 'temporary password' /var/log/mysqld.log     #查看默认root账号密码
2017-11-21T08:28:55.813102Z 1 [Note] A temporary password is generated for root@localhost: p=5qp7Qb+Tz.
$ ps -ef |grep mysql #验证mysql启动
root     25194     1  0 16:40 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql    25388 25194  0 16:40 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root     25634 23723  0 16:46 pts/0    00:00:00 grep --color=auto mysql
$ chkconfig mysql on #设置mysql开机启动