CentOS7.5二进制安装MySQL-8.0.12

mysql-8.0.12二进制包下载地址 MD5值 58bcd8af8b9d966140430ae4c846df73

https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz

mysql-8.0.13二进制包下载地址 MD5值 ea0b14eaf516784aa0f8af6015ccdbf2

https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz

mysql-8.0.14二进制包下载地址 MD5值 b9a04efa353f4b16d5c034a4e6e73cc8

https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.14-linux-glibc2.12-x86_64.tar.xz


1.安装依赖包

yum -y install -y gcc gcc-c++ autoconf bison-devel ncurses-devel libaio-devel numactl

2.创建mysql用户

useradd -M -s /sbin/nologin mysql

3.下载mysql-8.0.12二进制包

wget https://downloads.mysql.com/archives/get/file/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz

4.解压缩mysql二进制包到/usr/local

tar xf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/

5.修改目录名称、修改mysql目录所有者、做软连接

mv mysql-8.0.12-linux-glibc2.12-x86_64 /usr/local/mysql-8.0.12
ln -s /usr/local/mysql-8.0.12/ /usr/local/mysql

6.编辑主配置文件,mysql-8.0.12默认没有主配置文件

⚠️如果指定了mysql的socket文件位置,则必须添加[client]标签并同时指定socket文件位置,否则客户端会从/tmp下找socket文件

#备份原有/etc/my.cnf
mv /etc/my.cnf /etc/my.cnf.old

#以下为精简版主配置文件,后续根据实际情况修改
cat >> /etc/my.cnf <<'EOF'
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
user=mysql
log-error=/usr/local/mysql/data/error.log

[client]
socket=/var/lib/mysql/mysql.sock
EOF

6.创建socket文件目录

mkdir -p /var/lib/mysql

7.相关目录、文件授权

chown -R mysql.mysql /usr/local/mysql* /var/lib/mysql
chown mysql.mysql /etc/my.cnf

8.拷贝启动脚本

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

9.初始化mysql

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

mysql8.0.12初始化没有提示!!!

--initialize
--user                 #指定mysql用户
--basedir                 #指定mysql安装目录
--datadir                #指定mysql数据目录
--initialize-insecure        #不生成随机密码

10.添加mysql命令环境变量

#导出mysql命令环境变量
echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh

#使配置生效
source /etc/profile

11.配置systemd管理mysql

cat > /etc/systemd/system/mysqld.service <<'EOF'
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF

12.启动mysql、检查启动

#重新加载systemd系统服务
systemctl daemon-reload

#启动mysql并加入开机自启
systemctl start mysqld && systemctl enable mysqld

#查看mysql端口
$ netstat -ntpl  | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      31349/mysqld

13.连接mysql并设置密码

#进入mysql
mysql

#设置mysql密码
mysql> set password='123';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

到此,mysql8.0.12二进制安装完成!!!

泡泡吐肥皂o © gitbook.pptfz.top 2021 all right reserved,powered by Gitbook文件修订时间: 秃笔南波湾!!!

results matching ""

    No results matching ""