# 创建一个用户 mysql> create user keme@'localhost' identified by '123456'; # 给一个只读权限 mysql> grant select on *.* to keme@'localhost'; # 可以从本地登录 [root@mysql-150 ~]# mysql -u keme -p123456 # 把keme@'localhost' 给lock住,不让其使用 mysql> alter user keme@'localhost' account lock; # 在看看能不能从本地登录 [root@mysql-150 ~]# mysql -u keme -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 3118 (HY000): Access denied for user 'keme'@'localhost'. Account is locked. # 查看该用户是否锁定 mysql> select host,user,account_locked from mysql.user where user='keme'; +-----------+------+----------------+ | host | user | account_locked | +-----------+------+----------------+ | localhost | keme | Y | +-----------+------+----------------+ Y已锁定 # 然后解锁该keme用户 mysql> alter user keme@'localhost' account unlock; # 再去登录keme用户 [root@mysql-150 ~]# mysql -u keme -p123456
标签:150,keme,账号,MySQL,account,user,mysql,锁定,localhost From: https://www.cnblogs.com/shujuyr/p/18665848