环境
- 使用的版本Mysql5.7
-
Mysql 5.7修改密码
mysql> update mysql.user set authentication_string=password('新密码') where user='用户';
mysql> flush privileges;
用户管理
- 查看用户的授权列表
mysql> select * from information_schema.user_privileges;
- 创建用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
ex:
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'Admin66668888';
CREATE USER 'admin'@'%' IDENTIFIED BY '';
username : 你将创建的用户名,
host : 指定该用户在哪个主机上可以登陆,此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录,如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录;也可以指定某台机器可以远程登录;
password: 该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器。注意密码要满足自己数据库的安全要求,参考:mysql之validate_password_policy。
- 授权
GRANT ALL PRIVILEGES ON *.* TO admin@localhost IDENTIFIED BY 'admin';
-
1.问题:Host '222.35.5.75' is not allowed to connect to this MySQL server
排查IP以及端口是否正确
查看防火墙以及允许访问的端口的安全组是否打开
mysql是否允许远端访问
mysql -uroot -p
输入密码如果能进去,执行以下
mysql> use mysql
mysql> select t.host from user t where t.user='root';
+--------------+
| host |
+--------------+
| localhost |
+--------------+
出现以上表示只能本地访问mysql
执行以下命令,重启mysql即可。
update user set host='%' where user='root';
网友评论