这两天买了台阿里云ECS服务器,准备安装mysql8,看了网上安装流程,结果五花八门,没有一个正确的,在这里我整理了下安装步骤分享下!
https://downloads.mysql.com/archives/community/
https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
yum install libaio
将包mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz放到 /usr/local/目录下
cd /usr/local/
tar -xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.27-linux-glibc2.12-x86_64 mysql8
mkdir data
mkdir tmp
groupadd mysql
useradd -g mysql mysql
chown -R mysql.mysql /usr/local/mysql8/
vi /etc/my.cnf
配置
[mysqld]
basedir = /usr/local/mysql8
datadir = /usr/local/mysql8/data
port = 3306
socket = /usr/local/mysql8/tmp/mysql.sock
#必填项
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
socket = /usr/local/mysql8/tmp/mysql.sock
cd bin
./mysqld --initialize --user=mysql
切换到support-files目录
cp support-files/mysql.server /etc/init.d/mysql.server
chmod +x /etc/init.d/mysql.server
chkconfig --add mysql.server
ln -sf /usr/local/mysql8/bin/mysql /usr/bin
service mysql.server start
我刚随机生成的密码是lrwQR75;ljAL 见上述初始化信息
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
flush privileges;
其中123456为新密码
切换到mysql库
use mysql;
select host,user,plugin from user;
update user set host = '%' where user ='root';
flush privileges;
其中plugin为caching_sha2_password 远程连接需要带上后缀allowPublicKeyRetrieval = true
create database testdb;
DBeaver连接
修改驱动属性allowPublicKeyRetrieval = true
缺少依赖libaio-devel.x86_64
yum install libaio-devel.x86_64
没有XXX权限,mysql安装目录授权,命令读写权限刷一下!!!