搭建lnmp环境-mysql(第五步)

版本mysql 5.7

 

先删除系统自带的db

 

新建文件夹/data/download

进入后下载

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

安装 

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022(这里要用2022)

yum install mysql-server

systemctl start mysqld

systemctl enable mysqld (开机启动)

获取临时密码

grep 'temporary password' /var/log/mysqld.log

 

把MySQL的密码校验强度改为低风险

set global validate_password_policy=LOW;

修改MySQL的密码长度为6位

set global validate_password_length=6;

修改MySQL密码为123456

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

 

查看防火墙状态,如果开启则把防火墙给关闭

systemctl status firewalld

systemctl stop firewalld

systemctl disable firewalld (取消开机启动)

# 连接数据库
mysql -uroot -p

# 切换到mysql表
use mysql;

# 查看root的host权限
select host from user where user='root';

# 修改登录权限
update user set host = '%' where user ='root';

# 刷新
flush privileges;

# 再次查看权限
select host from user where user='root';

 

在/etc/my.cnf

新增配置:

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
不然有些sql会报错~

 

posted @ 2023-12-29 11:44  猫猫客服  阅读(6)  评论(0编辑  收藏  举报