簡介
MySQL8.0已經(jīng)正式發(fā)布了,提供了很多新特性,性能提升也是很明顯。
下載
可以直接使用國內(nèi)的鏡像源進(jìn)行下載
wget -c mirrors.huaweicloud.com/mysql/Downloads/MySQL-8.0/mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xz
centos7上glibc已經(jīng)是2.17版本了,下載對(duì)應(yīng)的版本即可。
安裝
需要安裝系統(tǒng)依賴包
yum -y install libaio
解壓安裝
tar xvf mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xz
mv mysql-8.0.22-linux-glibc2.17-x86_64-minimal /usr/local/
cd /usr/local/
ln -s mysql-8.0.22-linux-glibc2.17-x86_64-minimal mysql
初始化
初始化的時(shí)候,需要指定運(yùn)行用戶,因此需要?jiǎng)?chuàng)建運(yùn)行用戶,并創(chuàng)建數(shù)據(jù)目錄
useradd -M -s /sbin/nologin mysql
mkdir -p /data/mysql8/data
chown mysql.mysql /data/mysql8/data
初始化
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/data/mysql8/data
初始化后,默認(rèn)的 用戶是root@localhost,沒有密碼
配置文件
vim /etc/my.cnf
[mysqld]
datadir=/data/mysql8/data
socket=/data/mysql8/mysql.sock
[client]
socket=/data/mysql8/mysql.sock
設(shè)置啟動(dòng)腳本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改對(duì)應(yīng)的程序和數(shù)據(jù)目錄
sed -i 's#^basedir=$#basedir=/usr/local/mysql#g' /etc/init.d/mysqld
sed -i 's#^datadir=$#datadir=/data/mysql8/data#g' /etc/init.d/mysqld
啟動(dòng)測試
/etc/init.d/mysqld start
/usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.22 MySQL Community Server - GPL
?
Copyright (c) 2000, 2020, 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>
?
總結(jié)
安裝很簡單,測試可以直接用。如果是生產(chǎn)環(huán)境中使用,具體的參數(shù)配置,可以慢慢測試調(diào)整。