centos7安装 Mysql

centos7安装 Mysql

1、下载:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
2、复制到centos7
3、解压:tar -xvf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
4、备注:如果删不掉的话可以试试这条命令:yum remove mysql-libs
然后依次安装:
  #rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm
  #rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm
  #rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm
  #rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm
5、启动服务:systemctl start mysqld.service
6、mysql运行状态:systemctl status mysqld.service
7、查看默认密码:grep 'temporary password' /var/log/mysqld.log 如:host:  #28sCr4e:IeN   (后面的为密码)
可能会有如下问题:
	1、ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
	解决:
		必须修改两个全局参数: 
		首先,修改validate_password_policy参数的值
		mysql> set global validate_password_policy=0; 
		再修改密码的长度
		mysql> set global validate_password_length=1;
		修改密码:ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; 
                2、开启mysql任何网络可见:mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; (centos)
	3、开启端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent   # 开放3306端口
	3、停止启动操作防火墙:systemctl stop firewalld  、  systemctl start firewalld  、查看开启的端口:firewall-cmd --zone=public --list-ports / firewall-cmd --list-ports


 8、命令:
	重启:systemctl restart mysqld.service





上一篇:centos7/rhel7升级openssh7.4p1到openssh8.5p1


下一篇:Linux安装mysql.5.7详细教学