准备工作
操作系统:CentOS 6.8
MySQL版本:Community 5.7.17
预备:下载MySQL的common, libs, client, devel, server五个rpm包,CentOS对应的版本是RedHat/Oracle
注:使用root用户安装,非root用户只能用源码编译安装
1. 查看是否已安装了MySQL相关组件
rpm -qa | grep -i mysql
2. 用rpm方式卸载已安装的MySQL的组件(如有必要)
rpm -e --nodeps xxx //xxx是已安装MySQL的组件
3. 用rpm方式安装MySQL(有依赖关系,按照下面顺序装)
rpm -ivh mysql-community-common-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.17-1.el6.x86_64.rpm
4. 启动MySQL
service mysqld start //最新版的MySQL服务改名为mysqld
5. 初始化MySQL
mysql_secure_installation
注:MySQL 5.7版本增加了密码强度验证插件,安装的时候会默认生成root密码,可在 /var/log/mysqld.log文件中搜索字符串”A temporary password is generated for root@localhost:”查看