shell>
mysql -u root
mysql>
DELETE FROM mysql.user WHERE Host='localhost' AND User='';
mysql>
FLUSH PRIVILEGES;
root 帳號密碼設定
shell>
mysql -u root
mysql>
UPDATE mysql.user SET Password = PASSWORD('newpwd
')
WHERE User = 'root';
mysql>
FLUSH PRIVILEGES;
新增其他帳號
1. 先以root身份登入
shell> mysql -u root mysql -p
2. mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION
這兩行都要,上面是local端執行,下面是遠端連進資料庫
若要設定使用者 userYYY 只能用特定 DB (ZZZ):
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON ZZZ.* TO 'userYYY'@'localhost' IDENTIFIED BY 'password';Query OK, 0 rows affected (0.00 sec)
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON ZZZ.* TO 'userYYY'@'%' IDENTIFIED BY 'password';
沒有留言:
張貼留言