CentOS 7 mysql 5.7社区版下载 安装 配置_0n

2020-07-08  本文已影响0人  0neBean
cat > /etc/yum.repos.d/mysql-community.repo <<EOF
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/ 
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
EOF
sudo yum makecache fast
yum -y install mysql-community-server
#启动
systemctl start mysqld
#查询
systemctl status mysqld
#停止
systemctl stop mysqld
#重启
systemctl restart mysqld
#自启动
systemctl enable mysqld
#关闭自启动
systemctl disable mysqld

mysql5.7 默认不支持很弱的密码 ,以下为了举例,将密码设置为'root',请不要这样做

awk '/temporary password/{print $NF}' /var/log/mysqld.log
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
flush privileges;
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;

编辑配置文件:

vim /etc/my.cnf

添加如下参数:

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
character-set-server=utf8

重启:

systemctl restart mysqld
上一篇下一篇

猜你喜欢

热点阅读