lampfree小站

学习交流lamp技术,笔记记录

mysql57的安装和修改默认密码

评论

安装使用 rpm 方式

  1. 安装源

    wget http://repo.mysql.com//mysql57-community-release-el6-7.noarch.rpm
    rpm -i mysql57-community-release-el6-7.noarch.rpm
  1. 安装mysql mysqld\

    yum install mysql mysql-server
  2. 跳过授权直接登录,这样可以直接修改密码
    方法修改 my.conf

    vim /etc/my.conf
    #  添加一行
    skip-grant-tables
  3. 启动mysql

    service mysqld start
    # 或者 service mysqld restart
  4. 修改密码

    update mysql.user SET authentication_string=password (’sfew5@#@w5er2sdf’) where user=’root’;
    flush privileges;
    set password = PASSWORD('sfew5@#@w5er2sdf');

    需要注意的是密码要复杂点,因为如果密码简单是不行的。
    会提示这个 ,大概意思 密码不符合安全策略
    Your password does not satisfy the current policy requirements


密码的安全策略

set global validate_password_policy=0;
# 0 表示比较低的安装策略, 满足长度就可以
# 1 表示,满足长度、大小写、特殊符号
# 2 满足1并且 dictionary file

密码的长度

set global validate_password_length=1;

查看

mysql> show variables like 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file    |       |
| validate_password_length             | 4     |
| validate_password_mixed_case_count   | 1     |
| validate_password_number_count       | 1     |
| validate_password_policy             | LOW   |
| validate_password_special_char_count | 1     |
+--------------------------------------+-------+
6 rows in set (0.00 sec)