Linux mysql5.7.18创建数据库并授权用户
把某个数据库授权给某个用户,并设置密码mysql -u root -p123456添加Mysql用户mysql> CREATE DATABASE testdb CHARACTER SET utf8 COLLATE utf8_bin;mysql> GRANT ALL ON db_name.* TO user_name@'%' IDENTIFIED BY 'p...
·
把某个数据库授权给某个用户,并设置密码
mysql -u root -p123456
添加Mysql用户
mysql> CREATE DATABASE testdb CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT ALL ON db_name.* TO user_name@'%' IDENTIFIED BY 'passwprd';
mysql> flush privileges;
远程访问mysql:
mysql -h192.3.3.3 -uroot -p123456
密码复杂度不够的修改:
select @@validate_password_policy;
SHOW VARIABLES LIKE 'validate_password%';
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.05 sec)
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
修改用户密码
通过登录mysql系统,
mysql -uroot -p Enter password: 【输入原来的密码】 mysql>use mysql; mysql> update user set password=passworD("test") where user='root'; mysql> flush privileges;
mysql> exit;
注意:如果Mysql的版本是5.7及以上的话update语句如下:
mysql> update user set authentication_string=passworD("test") where user='root';
mysql> flush privileges;
权限
show grants for testuser; # 查询某个用户的权限
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%'; #把数据库所有权限授权给testuser
GRANT ALL PRIVILEGES ON productdb.* TO 'testuser'@'%'; #把数据库名为productdb所有授权给testuser
REVOKE ALL PRIVILEGES ON `productdb`.* FROM 'testuser'@'%'; #回收testuser对数据库名为productdb的所有授权
flush privileges;
更多推荐
已为社区贡献1条内容
所有评论(0)