下载mysql
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm 解压
yum install mysql-community-server 安装服务
systemctl start mysqld.service 启动服务
grep 'temporary password' /var/log/mysqld.log 查看临时密码
mysql -uroot -p
mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误,如下图所示
set global validate_password_policy=0; 修改密码安全等级
image.pngset global validate_password_length=6; 修改密码长度
image.png
允许远程连接
mysql>use mysql;
mysql>update user set host = '%' where user= 'root';
mysql> grant all privileges on . to 'root'@'%' with grant option;
mysql>flush privileges;
本地连接出现2003错误
image.png解决办法关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service #禁止firewall开机启动
再次本地连接
如果你centos版本低可以安装低版本mysql
yum install -y mysql-server mysql mysql-devel
image.png
service mysqld start
最后设置root账号密码为root:mysqladmin -u root password 'root'
进入mysql
允许远程连接
mysql> GRANT ALL PRIVILEGES ON . TO root@"%" IDENTIFIED BY "root";
mysql> flush privileges;
网友评论