标签:validate 用户创建 开机 grep alter nbsp centos7 file 本地
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum install mysql-community-server
systemctl start mysqld
systemctl enable mysqld
获取初始化密码:grep "password" /var/log/mysqld.log
初始密码:uf#jvc*X:21s
连接数据库:mysql -uroot -puf#jvc*X:21s
通过以下命令修改root密码:ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘@Daben123‘;
CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ identified by ‘root‘; //给全部权限
如创建一个test用户,密码为test123,可以进行远程登录:
mysql> create user ‘test‘@‘%‘ identified by ‘@Test123‘;
如果用户创建错了,肯定要支持删除操作,使用命令:mysql> drop user ‘test‘%‘host‘;
授权test用户拥有所有数据库的所有权限:
mysql>grant all privileges on *.* to ‘test‘@‘%‘ identified by ‘@Test123‘;
授权test用户拥有所有数据库的某些权限:
mysql> grant select,delete,update,create,drop on *.* to ‘test‘@‘%‘ identified by ‘@Test123‘;
授权test用户有testDB数据库的所有操作权限:
mysql> grant all privileges on testDB.* to ‘test‘@‘%‘ identified by ‘@Test123‘;
授权test用户有testDB数据库的某一部分权限:
mysql> grant select,update on testDB.* to test@‘%‘ identified by ‘@Test123‘;
刷新权限:
mysql> FLUSH PRIVILEGES
privileges - 用户的操作权限,如select,delete,update,create,drop等,如果要授予所有的权限可使用all;% 表示对所有非本地主机授权,不包括localhost。
8.补充:修改密码策略
如果只是修改为一个简单的密码,会报以下错误:
mysql> ALTER USER USER() IDENTIFIED BY ‘12345678‘;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
这个其实与validate_password_policy的值有关。
validate_password_policy有以下取值
Policy |
Tests Performed |
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 |
默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
修改validate_password_policy参数的值
Mysql>set global validate_password_policy=0;
标签:validate 用户创建 开机 grep alter nbsp centos7 file 本地
原文地址:https://www.cnblogs.com/yingjiyu/p/12190118.html