CentOS 7系统安装mysql5.7的详细步骤如下

卸载mariadb

检测系统自带的mariadb

rpm -qa | grep mariadb

卸载自带的mariadb(根据实际显示的版本)

rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64

安装mysql5.7

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server

启动mysql服务

systemctl start mysqld.service
systemctl enable mysqld.service
systemctl status mysqld.service

配置mysql

获取初始密码

grep "password" /var/log/mysqld.log

登录mysql

mysql -uroot -p

修改root用户密码,将下面的123456改为自己的密码(强密码)

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

赋予root用户远程访问权限

use mysql;
update user set host = "%" where user = "root";
flush privileges;

其他配置

设置密码强度(不建议)

set global validate_password_policy=0;  
set global validate_password_length=4; 

创建新用户

CREATE USER 'user'@'%' IDENTIFIED BY '123456';
GRANT all privileges ON *.* TO 'user'@'%';
flush privileges;

常用配置(忽略表大小写、最大连接数等)

vim /etc/my.cnf

在[mysqld]下添加如下配置并保存

lower_case_table_names=1
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
max_connections=10000
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
最后修改:2021 年 09 月 14 日 09 : 27 AM
如果觉得我的文章对你有用,请随意赞赏