欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

centos7.6 安装Mysql5.7

程序员文章站 2022-04-15 15:14:56
#安装Mysqlwget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpmyum localinstall mysql57-community-release-el7-8.noarch.rpmyum repolis ......

#安装mysql
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
cp /etc/my.cnf /etc/my.cnf_`date +%y%m%d%h%m%s`
mysql_pass=$(/usr/bin/grep 'temporary password' /var/log/mysqld.log | /usr/bin/grep 'root@localhost:' | /usr/bin/sed 's/^.*root@localhost: //g')
echo $mysql_pass
mysql -uroot -p$mysql_pass

# mysql修改安全策略
# 查看当前策略
# show variables like 'validate_password%';
# 修改策略项
# set global validate_password_policy=0;
# set global validate_password_mixed_case_count=0;
# set global validate_password_special_char_count=0;
# set global validate_password_length=6;
# set password for 'root'@'localhost' = password('新的密码');
# flush privileges;
# mysql 设置外网访问
# grant all privileges on *.* to '用户名'@'%' identified by '当前密码' with grant option;
# flush privileges;