linux 安装mysql

操作系统: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
  • 1
  • 1

2. 用rpm方式卸载已安装的MySQL的组件(如有必要)

rpm -e --nodeps xxx     //xxx是已安装MySQL的组件
  • 1
  • 1

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

4. 启动MySQL

service mysqld start     //最新版的MySQL服务改名为mysqld
  • 1
  • 1

5. 初始化MySQL

mysql_secure_installation
  • 1
  • 1

  注:MySQL 5.7版本增加了密码强度验证插件,安装的时候会默认生成root密码,可在 /var/log/mysqld.log文件中搜索字符串”A temporary password is generated for root@localhost:”查看

[root@localhost /]# rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm

warning: mysql-community-server-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

/usr/bin/perl is needed by mysql-community-server-5.7.11-1.el6.x86_64

libaio.so.1()(64bit) is needed by mysql-community-server-5.7.11-1.el6.x86_64

libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.11-1.el6.x86_64

libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.11-1.el6.x86_64

libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.11-1.el6.x86_64

perl(File::Path) is needed by mysql-community-server-5.7.11-1.el6.x86_64

perl(Getopt::Long) is needed by mysql-community-server-5.7.11-1.el6.x86_64

perl(POSIX) is needed by mysql-community-server-5.7.11-1.el6.x86_64

perl(strict) is needed by MySQL-community-server-5.7.11-1.el6.x86_64

解决方法

yum install numactl -y

yum install libaio -y

yum install perl -y

需要的离线包

numactl-2.0.9-2.el6.x86_64

libaio-0.3.107-10.el6.x86_64

perl-5.10.1-141.el6_7.1.x86_64.rpm

perl-Module-Pluggable-3.90-141.el6_7.1.x86_64.rpm

perl-Pod-Escapes-1.04-141.el6_7.1.x86_64.rpm

perl-Pod-Simple-3.13-141.el6_7.1.x86_64.rpm

perl-libs-5.10.1-141.el6_7.1.x86_64.rpm

perl-version-0.77-141.el6_7.1.x86_64.rpm