CentOS 8 安装 MySQL 8

wget https://dev.mysql.com/get/mysql80-community-release-el8-4.noarch.rpm;
rpm -ivh mysql80-community-release-el8-4.noarch.rpm;
yum install mysql-server;
chown -R mysql:mysql /data/mysql
systemctl enable mysqld;
systemctl start mysqld;

查看初始密码:

grep "password" /var/log/mysql/mysqld.log

设置:

port=13307
max_connections=1024
lower_case_table_names=1
default-time_zone = '+8:00'

以指定设置创建数据库:

mysqld --defaults-file=my.ini --initialize –console

创建root@%用户:

alter user 'root'@localhost' identified by 'JoyCode@2022';
create user 'root'@'%' identified by 'JoyCode@2022';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;#8以后
flush privileges;

若密码过于简单,可关闭密码验证:

set global validate_password_policy=0;
set global validate_password_length=1;
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享