二進制安裝安裝mysql 8.0.20

MySQL最新版本8.0.20正式發佈。與以前8.0的系列版本同樣,此次的發行版除了包含缺陷修復,也一樣包括新功能。下面快速瀏覽一下。關鍵字:hash join、InnoDB雙寫緩衝、二進制日誌事務壓縮。
下載mysql8.0.20二進制安裝包
環境:centos7
打開mysql官方下載連接 https://dev.mysql.com/downloads/mysql/
而後選擇操做系統爲linux通用、結構是X86,64二進制安裝包
在這裏插入圖片描述
將二進制安裝包上傳至Linux服務器
在這裏插入圖片描述mysql

下載相關依。

[15:12:04 root@a7 ~]#yum -y install make gcc-c++ cmake bison-devel ncurses-devel  readline-devel  libaio-devel perl libaio wget lrzsz vim libnuma* bzip2 xz

關閉selinux

[15:35:17 root@a7 ~]#sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[15:35:51 root@a7 ~]#setenforce  0
setenforce: SELinux is disabled

建立mysql用戶並建立分組

[16:12:37 root@a7 ~]#groupadd mysql
[16:12:50 root@a7 ~]#useradd -r -g mysql -s /bin/false mysql

解壓安裝包

[16:14:21 root@a7 ~]#tar xf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz -C /usr/local/

建立軟鏈接並受權給root

[16:16:09 root@a7 ~]#cd /usr/local/
[16:16:15 root@a7 local]#ln -s mysql-8.0.20-linux-glibc2.12-x86_64/ mysql
[16:16:26 root@a7 local]#chown -R root.root /usr/local/mysql

準備環境變量

[16:19:15 root@a7 local]#echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[16:19:31 root@a7 local]#. /etc/profile.d/mysql.sh

生成數據庫文件,並獲取root密碼

[16:21:25 root@a7 local]#cd mysql/bin/
[16:21:34 root@a7 bin]#mysqld  --initialize --user=mysql --datadir=/data/mysql
2020-06-04T08:21:50.801657Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-06-04T08:21:50.801741Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.20-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 50807
2020-06-04T08:21:50.813829Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-06-04T08:21:51.535221Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-06-04T08:21:52.534587Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wP+gq-PW<1an        #密碼爲 root@localhost: wP+gq-PW<1an

開啓SSl

[16:21:54 root@a7 bin]#mysql_ssl_rsa_setup -d /data/mysql/

編寫配置文件

[16:24:54 root@a7 bin]#vim /etc/my.cnf

[mysqld]
datadir=/data/mysql     #只修改數據庫存放目錄
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

修改啓動服務腳本

[16:25:39 root@a7 bin]#cd /usr/local/mysql/support-files/       #進入support-files/目錄
[16:35:23 root@a7 support-files]#vim mysql.server
# 找到如下這項並修改成咱們定義的數據存放目錄,並保存退出

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=
datadir=/data/mysql

建立MySQL日誌、socket文件

由於沒有這兩個文件mysql會啓動不了linux

--建立日誌文件c++

[16:46:07 root@a7 support-files]#mkdir /var/log/mariadb/
[16:48:04 root@a7 support-files]#touch /var/log/mariadb/mariadb.log
[16:48:15 root@a7 support-files]#chown -R mysql.mysql /var/log/mariadb

--建立socket文件sql

[16:51:05 root@a7 support-files]#mkdir /var/lib/mysql
[16:52:38 root@a7 support-files]#chmod 777 /var/lib/mysql/      #權限給777以便mysql用戶的寫入

--建立pid文件和建立sock軟鏈接數據庫

[17:00:30 root@a7 support-files]#mkdir /var/run/mariadb
[17:01:30 root@a7 support-files]#chown -R mysql.mysql /var/run/mariadb/
[16:57:17 root@a7 support-files]#ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

添加服務啓動腳本

[16:35:23 root@a7 support-files]#cp mysql.server /etc/init.d/mysqld
[17:14:02 root@a7 support-files]#chkconfig --add mysqld     #設置爲開機啓動
[17:14:07 root@a7 support-files]#chkconfig --list
​
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.
​
      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.
​
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

啓動服務

[17:15:21 root@a7 support-files]#systemctl start mysqld
[17:15:24 root@a7 support-files]#ss -ntl | grep 3306
LISTEN     0      70        [::]:33060                 [::]:*                  
LISTEN     0      128       [::]:3306                  [::]:*

修改密碼

[17:15:43 root@a7 support-files]#mysqladmin -u root -p password 12345
Enter password:         #這是輸入剛纔生成數據庫文件,並獲取的root密碼
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
# 注意:12345 是你的新密碼
# 這是輸入剛纔生成數據庫文件,並獲取的root密碼
# 密碼修改完成

登陸mysql服務

[17:19:41 root@a7 support-files]#mysql -uroot -p12345
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.20 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>

更多文章和資料|點擊下方文字直達 ↓↓↓
阿里雲K8s實戰手冊
[阿里雲CDN排坑指南]CDN
ECS運維指南
DevOps實踐手冊
Hadoop大數據實戰手冊
Knative雲原生應用開發指南
OSS 運維實戰手冊vim

相關文章
相關標籤/搜索