最近公司服务器由某数码迁移至阿里云,之前用的是mysql 5.6在迁移,查了下新版本的MySQL的新特性。发现mysql 8针对InnoDB 引擎做了性能提升,而且号称比5.7快2倍。所以决定直接跳过5.7,升级至8.0。以下是安装过程记录。
[root@izbp1es7c0 soft]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar
[root@izbp1es7c0 soft]# tar -xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar
mysql-community-libs-8.0.11-1.el7.x86_64.rpm
mysql-community-common-8.0.11-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-8.0.11-1.el7.x86_64.rpm
mysql-community-devel-8.0.11-1.el7.x86_64.rpm
mysql-community-server-8.0.11-1.el7.x86_64.rpm
mysql-community-client-8.0.11-1.el7.x86_64.rpm
mysql-community-server-minimal-8.0.11-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.11-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.11-1.el7.x86_64.rpm
mysql-community-test-8.0.11-1.el7.x86_64.rpm
[root@izbp1es7c0 soft]# rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm
warning: mysql-community-common-8.0.11-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-8.0.11-1.e################################# [100%]
[root@izbp1es7c0 soft]# rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm
warning: mysql-community-libs-8.0.11-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-8.0.11-1.el7################################# [100%]
[root@izbp1es7c0 soft]# rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm
warning: mysql-community-client-8.0.11-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-8.0.11-1.e################################# [100%]
[root@izbp1es7c0 soft]# rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm
warning: mysql-community-server-8.0.11-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-8.0.11-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.11-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.0.11-1.el7.x86_64
此时提升错误,需要安装libaio.so
[root@izbp1es7c0 soft]# yum install libaio
再次安装 mysql-community-server-8.0.11-1.el7.x86_64.rpm
[root@izbp1es7c0bwaldjl2dzb0z soft]# rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm
warning: mysql-community-server-8.0.11-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-8.0.11-1.e################################# [100%]
至此mysql 安装完成,接下来进行对mysql 进行配置。
[root@izbp1es7c0 soft]# mysqld --initialize
此命令会在/var/log/mysqld.log生成一个随机密码,找到这个密码后面要用到
[root@izbp1es7c0 soft]# chown mysql:mysql /var/lib/mysql -R
[root@izbp1es7c0 soft]# systemctl start mysqld.service
[root@izbp1es7c0 soft]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
[root@izbp1es7c0 soft]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>