创建用户:

groupadd mysql
useradd -m -g mysql mysql -s /sbin/nologin

下载压缩

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
tar xzvf mysql-8.0.16-linux-glibc2.12-x86_64.tar -C /usr/local/
mv /usr/local/mysql-8.0.16-linux-glibc2.12-x86_64 /usr/local/mysql

修改权限

chown mysql.mysql /usr/local/mysql/data

初始化数据库:

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

配置文件

[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /usr/local/mysql/tmp/mysql.sock

[client]
default-character-set=utf8
socket= /usr/local/mysql/tmp/mysql.sock

[mysql]
default-character-set=utf8
socket= /usr/local/mysql/tmp/mysql.sock

chmod 777 /usr/local/mysql/tmp/

配置环境变量

vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
source /etc/profile

启动mysql:

cp mysql.server /etc/init.d/mysql
service mysql start

修改密码:

5.8
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

5.7
update mysql.user set authentication_string=password('vabesrb2oy') where user='root';

5.6:
update mysql.user set Password=password('vabesrb2oy') where user='root';

报错:

./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
yum install -y libaio

02-09 19:15