MySQL的介绍和安装
-
MySQL 分支
Oracle
Percona
Mariadb
RDS
TX -
MySQL 企业版本选择
5.7 : 5.7.28+
8.0 : 8.0.18+
GA 6-12月版本,GA15-20版本以上的.
下载路径
https://downloads.mysql.com/archives/community/
4. 安装MySQL 8.0.20
上传和解压
[root@db01 opt]# tar xf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
[root@db01 opt]# ln -s /opt/mysql-8.0.20-linux-glibc2.12-x86_64 /usr/local/mysql
[root@db01 mysql]# vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
[root@db01 mysql]# source /etc/profile
[root@db01 mysql]# mysql -V
mysql Ver 8.0.20 for Linux on x86_64 (MySQL Community Server - GPL)
### 4.3 卸载无用软件
[root@db01 ~]# yum remove -y mariadb-libs
### 4.4 创建用户
[root@db01 ~]# useradd mysql
### 4.5 创建目录并授权
[root@db01 ~]# mkdir -p /data/3306/data
[root@db01 ~]# chown -R mysql. /data
### 4.6 准备配置文件
[root@db01 ~]# vim /etc/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/3306/data
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
### 4.7 初始化MySQL系统数据
[root@db01 mysql]# yum install -y libaio-devel
正确的输出:
[root@db01 mysql]# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306/data
2020-12-14T10:27:26.083747Z 0 [System] [MY-013169] [Server] /opt/mysql-8.0.20-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 2205
2020-12-14T10:27:26.176690Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-12-14T10:27:31.329930Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-12-14T10:27:34.098237Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@db01 mysql]#
4.8 准备启动脚本
[root@db01 support-files]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
sys-v :
[root@db01 support-files]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL... SUCCESS!
[root@db01 support-files]#
systemd:
[root@db01 support-files]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
[root@db01 support-files]#
[root@db01 support-files]# systemctl restart mysqld
[root@db01 support-files]# systemctl stop mysqld