时间:2021-07-01 10:21:17 帮助过:30人阅读
mysql 用户和权限管理 首先mysql root用户登录 [root@xx ~]# mysql -u root -p Enter password: 输入密码 切换数据库 mysql use mysql; 创建一个用户 mysql insert into user(host,user,password) values ("%","game",password("xxxxx"));Query OK, 1 row aff
mysql 用户和权限管理[root@xx ~]# mysql -u root -p Enter password: 输入密码
mysql> use mysql;
mysql> insert into user(host,user,password) values ("%","game",password("xxxxx")); Query OK, 1 row affected, 4 warnings (0.00 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql> create database game; Query OK, 1 row affected (0.06 sec)
mysql> grant all privileges on game.* to game@"%" identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec)
mysql>grant select,update on game.* to game@localhost identified by 'xxxx';
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql>update mysql.user set password=password('新密码') where User="game" and Host="%";
mysql>DELETE FROM user WHERE User="game" and Host="localhost"; mysql>flush privileges;
mysql> show grants for game; +-----------------------------------------------------------------------------------------------------+ | Grants for game@% | +-----------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'game'@'%' IDENTIFIED BY PASSWORD '*6830234338985B955032067DE689AFC3ECD27EEA' | | GRANT ALL PRIVILEGES ON `game`.* TO 'game'@'%' | +-----------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)
revoke all on game.* from game@%;