多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
> mysql安装5.7,确定不是mariadb * [ ] .rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm #下载 * [ ] .yum install yum-utils -y #装源 * [ ] .yum-config-manager --disable mysql56-community   # 禁用MySQL5.6的源 * [ ] .yum-config-manager --enable mysql57-community-dmr # 启用MySQL5.7的源 * [ ] .yum repolist enabled | grep mysql * [ ] .yum install mysql-community-server  #安装mysql >先卸载mariaDb ``` yum remove mariadb 删除配置文件: rm -f /etc/my.cnf 删除数据目录: rm -rf /var/lib/mysql/ ``` >可能会报错的地方 1. mysql-community-server-5.7.20-1.el6.x86_64 (mysql57-community)需要libsasl2.so.2()(64bit) * 解决方法 修改 源文件(vim /etc/yum.repos.d/mysql-community.repo): ``` [mysql57-community] name=MySQL 5.7 Community Server ## baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/    ##修改这里 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    ``` 2.旧的安装包和现在的冲突 ``` Transaction check error: file /usr/share/mysql/charsets/Index.xml from install of mysql-community-common-5.7.27-1.el7.x86_64 conflicts with file from package MariaDB-common-10.2.18-1.el7.centos.x86_64 ``` * 解决方法(删除旧的安装包) rpm -e MariaDB-common-10.2.18-1.el7.centos.x86_64 --nodeps >安装 yum install mysql-community-server >启动 ``` systemctl  start mysqld         #启动mysql systemctl  status mysqld      #查看mysql启动状态 ``` >修改密码 1. 查询初始密码(grep 'temporary password' /var/log/mysqld.log ) 2. mysql -uroot -p 3. 输入刚才查询的初始密码 4. 设置密码校验关闭和密码长度设置允许为0 ~~~ set global validate_password_policy=0; set global validate_password_length=0; ~~~ 5. 修改初始密码(SET PASSWORD = PASSWORD('abc1233');) 6. 如果要修改密码为空,必须要关掉密码校验,否则会出现 **Your password does not satisfy the current policy requirements** 7. 降低密码校验长度,密码校验长度由多个值组成,需要全部设置为0 ``` SHOW VARIABLES LIKE 'validate_password%'; ``` ![](https://img.kancloud.cn/bd/07/bd0701f064af320ffdbda9c4cf996a72_529x178.png) ``` set global validate_password_mixed_case_count=0; set global validate_password_number_count=0; set global validate_password_special_char_count=0; set global validate_password_length=0; ``` 这样就可以设置密码为空了 8. 设置密码为空 ``` update user set authentication_string=password('') where user='root' and host='localhost'; ``` 5.7的mysql或者maria字段是password 9. 刷新权限 ``` flush privileges; ```