首页 文章 centos7/8 安装mysql

centos7/8 安装mysql

发布时间:2020-07-20 16:06:44 作者:Soul-Yang 阅读量:923

1.下载mysql  软件

官网版本地址: https://dev.mysql.com/downloads/mysql/

2.解压安装包并安装。

# tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar

 严格按照顺序安装:

mysql-community-common-5.7.29-1.el7.x86_64.rpm、

mysql-community-libs-5.7.29-1.el7.x86_64.rpm、

mysql-community-client-5.7.29-1.el7.x86_64.rpm、

mysql-community-server-5.7.29-1.el7.x86_64.rpm这四个包

# rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
# rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm

3.配置数据库

vim /etc/my.cnf

添加这三行

skip-grant-tables character_set_server=utf8 init_connect='SET NAMES utf8'


skip-grant-tables:跳过登录验证

character_set_server=utf8:设置默认字符集UTF-8

init_connect='SET NAMES utf8':设置默认字符集UTF-8

4.启动mysql

启动mysql

systemctl start mysqld.service

5.设置密码

update mysql.user set authentication_string=password('123456') where user='root',如果是mysql8.0已上请看另一篇文章

6.设置密码策略(密码最短长度,以及复杂度等)

查看密码策

SHOW VARIABLES LIKE 'validate_password%';


set global validate_password_policy=LOW;

如果时mysql8.0 已上为:

set global validate_password.policy=LOW;
7.编辑my.cnf配置文件将:skip-grant-tables这一行注释掉,并重启mysql



  
留言
https://blog.key9.cn/
用户登录
您还没有写任何评论内容!
您已经评论过了!
只能赞一次哦!
您已经收藏啦!