先登錄MySQL
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';
添加用戶并設(shè)置數(shù)據(jù)庫具體權(quán)限:
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,INSERT,UPDATE,DELETE,CREATE,DROP ON expenses.* TO 'custom'@'host47.example.com';
mysql>CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'obscure';
mysql>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,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');
以上所述是小編給大家介紹的Mysql 5.6添加修改用戶名和密碼的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:- MySQL 客戶端不輸入用戶名和密碼直接連接數(shù)據(jù)庫的2個方法