标签:medium 字符 password 技术 you server 设置 variables temporary
安装环境:
CentOS7 64位,MySQL5.7
原文链接:https://blog.csdn.net/xyang81/article/details/51759200
1. 配置yum源
在MySQL官网下载yum 源rpm安装包:http://dev.mysql.com/downloads/repo/yum/
复制链接,然后wget
下载MySQL源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装MySQL源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查MySQL源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
安装MySQL:
yum install mysql-community-server
启动sql服务
systemctl start mysqld
查看MySQL启动的状态
systemctl status mysqld
[root@192 sql]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2019-09-25 05:23:26 EDT; 16s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 2071 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OP) Process: 1979 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 2074 (mysqld) CGroup: /system.slice/mysqld.service └─2074 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Sep 25 05:23:22 192.168.142.131 systemd[1]: Starting MySQL Server... Sep 25 05:23:26 192.168.142.131 systemd[1]: Started MySQL Server.
设置开机启动
systemctl enable mysqld systemctl daemon-reload
修改root本地登陆密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep ‘temporary password‘ /var/log/mysqld.log
mysql -uroot -p ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY‘原始密码‘
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误,如下图所示:
通过环境变量查看MySQL密码策略的相关信息
show variables like ‘%password%‘;
validate_password_policy:密码策略,默认为MEDIUM策略
validate_password_dictionary_file:密码策略文件,策略为STRONG才需要
validate_password_length:密码最少长度
validate_password_mixed_case_count:大小写字符长度,至少1个
validate_password_number_count :数字至少1个
validate_password_special_char_count:特殊字符至少1个
上述参数是默认策略MEDIUM的密码检查规则。
共有以下几种密码策略:
策略 检查规则
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file
MySQL官网密码策略详细说明:http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy
修改密码:
set password=password(‘123456‘);
重启MySQL服务:
systemctl restart mysqld
设置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置
[mysqld] character_set_server=utf8 init_connect=‘SET NAMES utf8‘
重启服务,查看数据库编码
show variables like ‘%character%‘;
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
标签:medium 字符 password 技术 you server 设置 variables temporary
原文地址:https://www.cnblogs.com/wqzn/p/11582785.html