多用戶攻略:為MySQL數據庫添加新用戶
剛安裝完的MySQL中只有一個默認的用戶,這就是root@localhost,如果需要使數據庫被更多的用戶訪問使用,就需要添加新用戶, 在windows可以用下面兩種方法來添加:
使用GRANT語句:
grant select on test.* to 'yonghu'@'%' identified by 'some_pass' with grant option;
例子表示增加一 個用戶,名稱是yonghu,來自任何位置,密碼是some_pass可以對test數據庫的任何表進行select命令。
直接向grant表中插入用戶:
shell>mysql --user=root mysql
mysql>insert into user (Host,User,Password) values('localhost','shagua','');
mysql>flush privileges;表示將來自本機的用戶,名叫shagua,密碼為空,添加入數據庫。
(e129)