更新密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
安装Mysql yum库
rpm -Uvh http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
yum安装Mysql
yum -y install mysql-community-server
设置开机自启
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld // 检查Mysql服务状态
关闭防火墙
systemctl stop firewalldsystemctl disable firewalld
Linux有一个安全模块SELinux,用以限制用户和程序的相关权限,来确保系统的安全稳定。
vi /etc/sysconfig/selinuxSELINUX=disabled
查询默认密码
grep 'temporary password' /var/log/mysqld.log
登录客户端
第一次启动mysql,会在日志文件中生成root用户的一个随机密码,使用下面命令查看该密码。
mysql -uroot -p
降低设置密码安全级别
如果想设置简单密码,需要降低Mysql的密码安全级别。
set global validate_password_policy=LOW;set global validate_password_Length=4;
设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';grant all privileges on *,* to root@"%" identified by 'password' with grant option;flush privileges;
常见BUG
错误码1045
关闭防火墙,并执行下面命令
grant all privileges on *,* to root@"%" identified by 'password' with grant option;flush privileges;
IDEA:JDBC driver may have disabled TLS 1.1 and its earlier versions.
URL添加 enabledTLSProtocols=TLSv1.2
jdbc:mysql://localhost:3306?enabledTLSProtocols=TLSv1.2