CentOS 7版本下载
rpm -Uvh https://repo.mysql.com//yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
https://repo.mysql.com//yum/mysql-8.0-community/el/7/x86_64/mysql80-community-release-el7-3.noarch.rpm
[root@localhost ~]#yum list
[root@localhost ~]#yum -y install mysql-community-server
[root@localhost ~]#systemctl start mysqld
[root@localhost ~]#systemctl enable mysqld
[root@localhost ~]# lsof -i :3306
第一次通过# grep “password” /var/log/mysqld.log 命令获取MySQL的临时密码
[root@localhost ~]# grep “password” /var/log/mysqld.log
2018-05-24T09:51:57.585660Z 1 [Note] A temporary password is generated for root@localhost: sJ?dm)NB2%o+
用该密码登录到服务端后,必须马上修改密码,不然操作查询时报错误
刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
如果想设置简单密码,如下操作:
方法一:首先,修改validate_password_policy参数的值
mysql> set global validate_password_policy=0; #定义复杂度
mysql> set global validate_password_length=1; #定义长度 默认是8
mysql> set password for ‘root’@’localhost’=password(‘311311’);
mysql> flush privileges;
方法二:在/etc/my.cnf 可关闭密码强度审计插件,重启mysql服务
validate-password=ON/OFF/FORCE/FORCE_PLUS_PERMANENT: 决定是否使用该插件(及强制/永久强制使用)。
方法三:mysql> alter user user() identified by ‘>F.BT,r%n123’;
mysql> flush privileges;
查看安装后的文件
[root@localhost ~]# rpm -qa | grep mysql
mysql-community-server-5.7.22-1.el7.x86_64
mysql57-community-release-el7-10.noarch
mysql-community-common-5.7.22-1.el7.x86_64
mysql-community-client-5.7.22-1.el7.x86_64
mysql-community-libs-compat-5.7.22-1.el7.x86_64
mysql-community-libs-5.7.22-1.el7.x86_64
[root@localhost ~]# rpm -ql mysql-community-server-5.7.22-1.el7.x86_64
/etc/logrotate.d/mysql
/etc/my.cnf
/usr/sbin/mysqld
/var/lib/mysql
/var/lib/mysql-files
/var/run/mysqld