二进制安装安装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二进制安装包
二进制安装安装mysql 8.0.20
将二进制安装包上传至Linux服务器
二进制安装安装mysql 8.0.20

下载相关依。

[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会启动不了

--创建日志文件

[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文件

[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 运维实战手册

二进制安装安装mysql 8.0.20

上一篇:Windows7下PostgreSQL安装小记


下一篇:数据库-表结构设计性能优化