shell> MysqL --user=root MysqL
有密码的需要添加 –password 或-p 选项
MysqL>CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';
MysqL>GRANT ALL PRIVILEGES ON *.* TO 'finley'@'localhost' WITH GRANT OPTION;
MysqL>CREATE USER 'finley'@'%' IDENTIFIED BY 'some_pass';
MysqL>GRANT ALL PRIVILEGES ON *.* TO 'finley'@'%' WITH GRANT OPTION;
MysqL>CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin_pass';
MysqL>GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
MysqL>CREATE USER 'dummy'@'localhost';
MysqL>CREATE USER 'custom'@'localhost' IDENTIFIED BY 'obscure';
MysqL>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON bankaccount.* TO 'custom'@'localhost';
MysqL>CREATE USER'custom'@'host47.example.com' IDENTIFIED BY 'obscure';
MysqL>GRANT SELECT,DROP ON expenses.* TO 'custom'@'host47.example.com';
MysqL>CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'obscure';
MysqL>GRANT SELECT,DROP ON customer.* TO 'custom'@'%.example.com';
MysqL>DROP USER 'jeffrey'@'localhost';
修改密码:
MysqL>SET PASSWORD FOR 'jeffrey'@'localhost' = PASSWORD('mypass');
MysqL>SET PASSWORD = PASSWORD('mypass');