liunx环境下安装mysql5.7及以上版本

 

1.系统环境

#cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core) 
#getenforce
Disabled
#systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
    Docs: man:firewalld(1)

2.配置yum源

#cd /etc/yum.repos.d
#vi mysql5.7.repo
[mysql5.7-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


[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

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


##注意: 不用校验时mysql下载安装速度快,即将1更改为0! 我的系统是linux7,所以相应的baseurl中的地址要更改为linux7, 即http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/。如果系统是linux6,请为http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ #清理缓存存储库 yum clean all #创建缓存存储库 yum makecache

3.查看是否有mysql安装包

yum repolist enabled | grep mysql

4.mysql的安装使用

#yum install mysql-community-server -y

#systemctl start mysqld.service

#mysql -V

//5.7以上版本的MySQL没有root的空密码
可以在配置文件中修改设置使用简单密码,/etc/my.cnf
validate_password_policy=0  //只匹配长度,默认8位
validate_password_length=4  //最小长度4位

#查看系统默认的root密码
grep 'temporary password' /var/log/mysqld.log
2019-06-23T11:13:14.861450Z 1 [Note] A temporary password is generated for root@localhost: qa!>h#BOu6eJ
##密码即:qa!>h#BOu6eJ
#使用root账户登入并修改root密码
mysql -uroot -p
mysql>set global validate_password_policy=0; //设置密码设置匹配最小长度默认8位

mysql>set global validate_password_length=1; //修改密码的长度
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
##需要注意的是:
MySQL的 validate_password 插件默认安装。这将要求密码包含至少一个大写字母,一个小写字母,一个数字和一个特殊字符,并且密码总长度至少为8个字符。
mysql>show variables like 'validate_password%';

 

posted @ 2019-06-23 13:30  邓聪聪  阅读(591)  评论(0编辑  收藏  举报