无网络环境下安装MySQL5.7

1、系统环境:CentOS 7 64bit

2、需要的rpm包已经在本地

1、下载需要的rpm包:

mysql-community-client-5.7.18-1.el7.x86_64.rpm mysql-community-common-5.7.18-1.el7.x86_64.rpm mysql-community-libs-5.7.18-1.el7.x86_64.rpm mysql-community-server-5.7.18-1.el7.x86_64.rpm numactl-2.0.9-6.el7_2.x86_64.rpm numactl-devel-2.0.9-6.el7_2.x86_64.rpm numactl-libs-2.0.9-6.el7_2.x86_64.rpm perl-Data-Dumper-2.145-3.el7.x86_64.rpm libaio-0.3.109-13.el7.x86_64.rpm

2、安装rpm:

注意安装顺序

rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm rpm -ivh perl-Data-Dumper-2.145-3.el7.x86_64.rpm rpm -ivh numactl-libs-2.0.9-6.el7_2.x86_64.rpm rpm -ivh numactl-devel-2.0.9-6.el7_2.x86_64.rpm rpm -ivh numactl-2.0.9-6.el7_2.x86_64.rpm rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm

若安装时出现冲突,需要将以安装的卸载掉(rpm -e),然后继续安装。

安装完毕后,启动mysql:

service mysqld start

启动后进入MySQL时,会提示输入密码,该密码是初次安装是默认生成并保存在/var/log/mysqld.log中,可以通过一下命令查看:

cat /var/log/mysqld.log | grep password

输入密码登陆后,执行SQL语句时,会提示让修改密码,执行以下三句:

1: SET PASSWORD = PASSWORD('new password');2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;3: flush privileges;

退出后再次登陆,OK。