centos7 安装mysql 及修改密码

运行环境 | centos 7.0 | mysql 5.7

mysql安装

  • 官网下载MySQL rpm包
    1
    2
    rpm -ivh mysql57-community-release-el7-8.noarch.rpm
    yum install mysql-community-server

安装完后启动MySQL服务

1
service mysqld restart

设置密码:

1
update mysql.user set authentication_string=password('新密码') where user='用户';
  • 重启数据库后登陆不上
    /etc/my.cnf 最后加上
    skip-grant-tables
    重启服务,免密码登陆,修改密码
    1
    alter user 'root'@'localhost' identified by '新密码';

修改数据库远程登陆权限:

1
2
use mysql;
grant all privileges on *.* to 'root'@'%' identified by '新密码' with grant option;

创建用户密码规则修改

1
CREATE USER '用户'@'%' IDENTIFIED BY '密码';

创建报错 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

  • 查看权限
    1
    select @@validate_password_policy;

MEDIUM

1
SHOW VARIABLES LIKE 'validate_password%';
Variable_name Value
validate_password_check_user_name OFF
validate_password_dictionary_file
validate_password_length 8
validate_password_mixed_case_count 1
validate_password_number_count 1
validate_password_policy MEDIUM
validate_password_special_char_count 1

修改密码等级

1
set global validate_password_policy=LOW;

设置密码长度

1
set global validate_password_length=5;

刷新

1
FLUSH PRIVILEGES;
本文结束感谢您的阅读,本文原创–支持原创
顺便打点赏吧~ 有问题请联系我--strivedeer@163.com