mysql创建用户
GRANT ALL PRIVILEGES ON *.* TO username@'%' IDENTIFIED BY "password"
分配远程username所有库的访问权限。
任何数据库的任何表到用户username使用密码password。
1 GRANT ALL PRIVILEGES ON test_db.* TO user1@192.168.1.3 IDENTIFIED BY "password"
2 GRANT ALL PRIVILEGES ON test_db.* TO user2@192.168.1.% IDENTIFIED BY "password"
3 GRANT ALL PRIVILEGES ON test_db.* TO user3@192.168.1.0/10 IDENTIFIED BY "password"
很明显,第一句是分配用户user1只能在192.168.1.3上访问。第二句是在192.168.1网段内都能访问。第三句是ip 0-10 范围内的。
删除用户:
DELETE FROM user WHERE User="username" and Host="localhost";
最后别忘了这句.
FLUSH PRIVILEGES;