本教程为yum在线安装
一. MySQL官方地址 MySQL Yum仓库的RPM安装包
一 通过wget方式获取yum包
wget http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
二. 安装MySQL RPM安装包
yum localinstall mysql80-community-release-el7-1.noarch.rpm
看到安装MySQL8.0安装完成后可到/etc/yum.repos.d/目录下看到:
mysql-community.repo
mysql-community-source.repo
三. 安装MySQL
[root@*******0x2dru8ftg3uz yum.repos.d]# yum install mysql-community-server
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql80-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/10): epel/x86_64/group_gz | 84 kB 00:00:00
(2/10): base/7/x86_64/group_gz | 166 kB 00:00:00
(3/10): epel/x86_64/updateinfo | 922 kB 00:00:00
(4/10): extras/7/x86_64/primary_db | 104 kB 00:00:00
(5/10): base/7/x86_64/primary_db | 5.9 MB 00:00:00
(6/10): epel/x86_64/primary_db | 6.4 MB 00:00:00
(7/10): updates/7/x86_64/primary_db | 1.0 MB 00:00:00
(8/10): mysql80-community/x86_64/primary_db | 16 kB 00:00:00
(9/10): mysql-connectors-community/x86_64/primary_db | 20 kB 00:00:00
(10/10): mysql-tools-community/x86_64/primary_db | 41 kB 00:00:00
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.11-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.11-1.el7 for package: mysql-community-server-8.0.11-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.0 for package: mysql-community-server-8.0.11-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-8.0.11-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-8.0.11-1.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-8.0.11-1.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mysql-community-client.x86_64 0:8.0.11-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.0 for package: mysql-community-client-8.0.11-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.11-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:8.0.11-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:8.0.11-1.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================
Installing:
mysql-community-libs x86_64 8.0.11-1.el7 mysql80-community 2.2 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-libs-compat x86_64 8.0.11-1.el7 mysql80-community 2.1 M
replacing mariadb-libs.x86_64 1:5.5.56-2.el7
mysql-community-server x86_64 8.0.11-1.el7 mysql80-community 341 M
Installing for dependencies:
libaio x86_64 0.3.109-13.el7 base 24 k
mysql-community-client x86_64 8.0.11-1.el7 mysql80-community 26 M
mysql-community-common x86_64 8.0.11-1.el7 mysql80-community 537 k
Transaction Summary
=========================================================================================================================================
Install 3 Packages (+3 Dependent packages)
Total download size: 371 M
Is this ok [y/d/N]: y
Downloading packages:
(1/6): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.11-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-8.0.11-1.el7.x86_64.rpm is not installed
(2/6): mysql-community-common-8.0.11-1.el7.x86_64.rpm | 537 kB 00:00:00
(3/6): mysql-community-libs-8.0.11-1.el7.x86_64.rpm | 2.2 MB 00:00:00
(4/6): mysql-community-libs-compat-8.0.11-1.el7.x86_64.rpm | 2.1 MB 00:00:00
(5/6): mysql-community-client-8.0.11-1.el7.x86_64.rpm | 26 MB 00:00:01
(6/6): mysql-community-server-8.0.11-1.el7.x86_64.rpm | 341 MB 00:00:27
-----------------------------------------------------------------------------------------------------------------------------------------
Total 13 MB/s | 371 MB 00:00:28
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering "
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql80-community-release-el7-1.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-8.0.11-1.el7.x86_64 1/7
Installing : mysql-community-libs-8.0.11-1.el7.x86_64 2/7
Installing : mysql-community-client-8.0.11-1.el7.x86_64 3/7
Installing : libaio-0.3.109-13.el7.x86_64 4/7
Installing : mysql-community-server-8.0.11-1.el7.x86_64 5/7
Installing : mysql-community-libs-compat-8.0.11-1.el7.x86_64 6/7
Erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 7/7
Verifying : mysql-community-server-8.0.11-1.el7.x86_64 1/7
Verifying : mysql-community-client-8.0.11-1.el7.x86_64 2/7
Verifying : mysql-community-libs-8.0.11-1.el7.x86_64 3/7
Verifying : mysql-community-common-8.0.11-1.el7.x86_64 4/7
Verifying : mysql-community-libs-compat-8.0.11-1.el7.x86_64 5/7
Verifying : libaio-0.3.109-13.el7.x86_64 6/7
Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 7/7
Installed:
mysql-community-libs.x86_64 0:8.0.11-1.el7 mysql-community-libs-compat.x86_64 0:8.0.11-1.el7
mysql-community-server.x86_64 0:8.0.11-1.el7
Dependency Installed:
libaio.x86_64 0:0.3.109-13.el7 mysql-community-client.x86_64 0:8.0.11-1.el7 mysql-community-common.x86_64 0:8.0.11-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.56-2.el7
Complete!
完成之后数据库会有一个初始密码,可通过一下命令查看:
[root@*******2dru8ftg3uz log]# sudo grep 'temporary password' /var/log/mysqld.log
至此,MySQL8.0 安装完成,下面进行启动配置。
四、启动MySQL8.0
[root@**********2dru8ftg3uz log]# sudo service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@**********2dru8ftg3uz log]#
查看MySQL进程
[root@******0x2dru8ftg3uz log]# ps -ef |grep mysql
mysql 10746 1 4 15:22 ? 00:00:00 /usr/sbin/mysqld
root 10791 10479 0 15:22 pts/0 00:00:00 grep --color=auto mysql
[root@*********dru8ftg3uz log]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2018-05-15 15:22:19 CST; 7min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 10678 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 10746 (mysqld)
Status: "SERVER_OPERATING"
CGroup: /system.slice/mysqld.service
└─10746 /usr/sbin/mysqld
May 15 15:22:09 **********2dru8ftg3uz systemd[1]: Starting MySQL Server...
May 15 15:22:19 **********2dru8ftg3uz systemd[1]: Started MySQL Server.
停止MySQL服务:service mysqld stop
五、进行一些必要的配置
1、修改初始密码
查看默认密码
shell> sudo grep 'temporary password' /var/log/mysqld.log
使用默认密码登陆
shell> mysql -uroot -p
MySQL8.0修改密码需要有大小写字母、数字、特殊字符组合
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
2、外网/客户端访问问题 ERROR 1130
use mysql
update user set host='%' where user='root';
客户端报错:2059 执行
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Your password';
另外阿里云的防火墙默认端口是不开放的,需要在控制台进行设置,不打开端口外网也是访问不到的。
终于大功告成。