欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux安装MySql数据库5.7版本

程序员文章站 2022-05-27 09:41:10
...

 

1、下载YUM库。
    wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

2、安装YUM库
   shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
3、安装数据库
   shell > yum install -y mysql-community-server
4、启动MySql服务
   shell > systemctl start mysqld.service
5、mysql5.6版本以上会在日志中生成密码,

或者:

yum install mysql-server
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
service mysqld start
grep "password" /var/log/mysqld.log

日志位置:/var/log/mysqld.log

 

        查看密码:grep 'temporary password' /var/log/mysqld.log
[[email protected] /]# grep 'temporary password' /var/log/mysqld.log
2017-12-06T02:09:06.230000Z 1 [Note] A temporary password is generated for [email protected]: lYKouf=W1Sg

6、登录:
mysql -uroot -plYKouf=W1Sgh
7、修改密码

set global validate_password_policy=0;

ALTER USER USER() IDENTIFIED BY 'root123456';

flush privileges;

grant all privileges  on *.* to [email protected]'%' identified by 'root123456';
flush privileges;

 

8、这里可以对密码进行设置。

      set global validate_password_policy=0;

      set global validate_password_length=1;指密码长度

 

      validate_password_number_count
      validate_password_special_char_count
      validate_password_mixed_case_count
      global validate_password_length判断密码的标准就基于密码的长度
     其中,validate_password_number_count指定了密码中数据的长度,
               validate_password_special_char_count指定了密码中特殊字符的长度,
               validate_password_mixed_case_count指定了密码中大小字母的长度。
	查看密码的设置:
    SHOW VARIABLES LIKE 'validate_password%';