CentOS7安装mysql5.7
1、下载
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm (确保安装了wget)
2、安装
yum -y install mysql57-community-release-el7-10.noarch.rpm
3、安装mysql服务器
yum -y install mysql-community-server
4、配置mysql数据库
运行:systemctl start mysqld.service
查看状态:systemctl status mysqld.service
查看默认密码:grep "password" /var/log/mysqld.log
进入数据库:mysql -uroot -p
设置密码规范:
set global validate_password_policy=0;
set global validate_password_length=1;
设置新密码:ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
5、因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉
yum -y remove mysql57-community-release-el7-10.noarch
安装时遇到的问题:
远程MYSQL 1103错误 ERROR 1130: Host ... is not allowed to connect to
解决:
1.进入mysql
[root@localhost ~]# mysql -u root -p123456
2.选择mysql库
mysql> use mysql;
3.查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称)
mysql> select host,user from user where user='root';
4.修改host值(以通配符%的内容增加主机/IP地址),当然也可以直接增加IP地址
mysql> update user set host= '%' where user ='root';
5.刷新MySQL的系统权限相关表
mysql> flush privileges;