天天看點

centos7 安裝mysql8_CentOS7安裝mysql8簡介下載下傳安裝初始化啟動測試總結

簡介

MySQL8.0已經正式釋出了,提供了很多新特性,性能提升也是很明顯。

centos7 安裝mysql8_CentOS7安裝mysql8簡介下載下傳安裝初始化啟動測試總結

下載下傳

可以直接使用國内的鏡像源進行下載下傳

wget -c mirrors.huaweicloud.com/mysql/Downloads/MySQL-8.0/mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xz
           

CentOS7上glibc已經是2.17版本了,下載下傳對應的版本即可。

centos7 安裝mysql8_CentOS7安裝mysql8簡介下載下傳安裝初始化啟動測試總結

安裝

需要安裝系統依賴包

yum -y install libaio
           

解壓安裝

tar xvf  mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xzmv 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
           

初始化

初始化的時候,需要指定運作使用者,是以需要建立運作使用者,并建立資料目錄

useradd -M -s /sbin/nologin  mysqlmkdir -p /data/mysql8/datachown mysql.mysql /data/mysql8/data
           

初始化

/usr/local/mysql/bin/mysqld --initialize-insecure  --user=mysql --datadir=/data/mysql8/data
           

初始化後,預設的 使用者是[email protected],沒有密碼

配置檔案

vim /etc/my.cnf
           
[mysqld]datadir=/data/mysql8/datasocket=/data/mysql8/mysql.sock[client]socket=/data/mysql8/mysql.sock
           

設定啟動腳本

cp /usr/local/mysql/support-files/mysql.server   /etc/init.d/mysqld
           

修改對應的程式和資料目錄

sed -i 's#^basedir=$#basedir=/usr/local/mysql#g' /etc/init.d/mysqldsed -i  's#^datadir=$#datadir=/data/mysql8/data#g' /etc/init.d/mysqld
           

啟動測試

/etc/init.d/mysqld start
           
/usr/local/mysql/bin/mysqlWelcome to the MySQL monitor.  Commands end with ; or g.Your MySQL connection id is 9Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.​Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.​mysql> ​
           

總結

安裝很簡單,測試可以直接用。如果是生産環境中使用,具體的參數配置,可以慢慢測試調整。

centos7 安裝mysql8_CentOS7安裝mysql8簡介下載下傳安裝初始化啟動測試總結