centos7安装mysql8.0-二进制安装

官方参考手册:https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html

1.下载通用二进制安装包

下载地址:https://dev.mysql.com/downloads/mysql/
此处版本为:mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
下载直链:https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
centos7安装mysql8.0-二进制安装_第1张图片

2.卸载旧版本mysql、mariadb

rpm -qa|grep mariadb
rpm -qa|grep mysql
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

3.安装依赖

yum install libaio ncurses-compat-libs -y

4.添加mysql用户、用户组

不指定用户组时,默认生成一个同名用户组并加入
-r,指定为系统用户
-s,指定登录shell

useradd -r -s /bin/false mysql

5.解压软件包

安装目录为:/usr/local/mysql

cd /usr/local
tar xvf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
ln -s mysql-8.0.20-linux-glibc2.12-x86_64 mysql
export PATH=$PATH:/usr/local/mysql/bin (vim /etc/profile 写入文件永久生效)

6.???

该mysql-files目录为用作secure_file_priv系统变量的值提供了一个方便的位置

cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files

7.初始化mysql并启动

mysqld --initialize --user=mysql
mysql_ssl_rsa_setup
mysqld_safe --user=mysql &

8.注册服务并设置开机启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
service mysql.server restart 或 systemctl restart mysql.server
systemctl enable mysql.server 或 /sbin/chkconfig mysql.server on

9.修改密码并设置外网访问

alter user 'root'@'localhost' identified by '123456';
create user 'root'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%' with grant option;

你可能感兴趣的:(数据库)