MySQL5.7安装与配置

首先到mysql的官网下载yum repo配置文件

下载命令:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

然后进行yum源的安装:

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

安装完成后,就可以使用yum命令安装mysql了:

yum -y install mysql-server

启动mysql:

systemctl start mysqld

查看mysql状态:

systemctl status mysqld

获取mysql的临时密码:

grep ‘temporary password’ /var/log/mysqld.log

登录mysql:(密码为上一步骤获取的临时密码)

mysql -u root -p(此处不用输入密码,按下回车后会专门要你再输入密码的)

修改下数据库的配置

vi /etc/my.cnf # 修改之前记得备份

default-storage-engine=INNODB
character_set_server=utf8mb4
innodb_default_row_format=DYNAMIC
innodb_file_format=Barracuda
innodb_log_file_size=2G
sql_mode=ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

修改之后重启 systemctl restart mysqld

上一篇:mysql之linux yum安装及设置开机自启


下一篇:docker