参照:
https://www.runoob.com/mysql/mysql-install.html
https://www.cnblogs.com/shenjianping/p/10984540.html
mysql 获取地址
https://dev.mysql.com/downloads/mysql/
以下是安装步骤:
#获取mysql
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz
tar -xvJf mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz -C /usr/local/mysql
#修改权限
groupadd mysql
useradd -r -g mysql mysql
chown mysql:mysql -R /usr/local/mysql
mkdir -p mysql/data
修改 /etc/my.cnf 具体如下:
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket=/usr/local/mysql/mysql.sock
default_authentication_plugin=mysql_native_password
# 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
user=mysql
port=3306
character-set-server=utf8
#取消密码验证
skip-grant-tables
[mysqld_safe]
log-error=/var/log/mysql/mariadb.log
pid-file=/var/run/mysql/mariadb.pid
[client]
socket=/usr/local/mysql/mysql.sock
[server]
socket=/usr/local/mysql/mysql.sock
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
#因为最开始有修改权限的操作,这一部分如果不修改权限,会出现一些错误
chown mysql:mysql -R /var/log/mysql/
chown mysql:mysql -R /var/run/mysql/
cp mysql/support-files/mysql.server /etc/init.d/mysql
#可把mysql 路径添加到PATH
service mysql start
#可以安全启动