CentOS 7 mysql 5.7社区版下载 安装 配置_0n
2020-07-08 本文已影响0人
0neBean
- 创建mysql清华镜像源:
baseurl
决定了可以安装mysql 的版本,可以替换成需要安装的版本,具体的连接参考 清华yum源
这里安装了centos7适用的5.7版本
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
- 安装mysql
yum -y install mysql-community-server
- 运行mysql
#启动
systemctl start mysqld
#查询
systemctl status mysqld
#停止
systemctl stop mysqld
#重启
systemctl restart mysqld
#自启动
systemctl enable mysqld
#关闭自启动
systemctl disable mysqld
mysql5.7 默认不支持很弱的密码 ,以下为了举例,将密码设置为'root',请不要这样做
- 获取mysql默认安装密码
awk '/temporary password/{print $NF}' /var/log/mysqld.log
- 重置root用户密码
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