|
方法 用root用戶登陸,然后: grant all privileges on *.* to 創(chuàng)建的用戶名 @"%" identified by "密碼"; flush privileges; * 刷新剛才的內容* 格式:grant 權限 on 數(shù)據(jù)庫教程名.表名 to 用戶@登錄主機 identified by "用戶密碼"; @ 后面是訪問mysql的客戶端ip地址(或是 主機名) % 代表任意的客戶端,如果填寫 localhost 為 本地訪問(那此用戶就不能遠程訪問該mysql數(shù)據(jù)庫了)。 同時也可以為現(xiàn)有的用戶設置是否具有遠程訪問權限。如下: use mysql; update db set host = '%' where user = '用戶名'; (如果寫成 host=localhost 那此用戶就不具有遠程訪問權限) flush privileges; grant all privileges on *.* to 'myuser'@'%' identified by 'mypassword' with grant option;
方法二 1. 使用grant語句添加:首先在數(shù)據(jù)庫本機上用root用戶 登錄mysql(我是用遠程控制linux服務器,相當于在服務器本機登錄mysql了),然后輸入: mysql>grant all privileges on *.* to admin@localhost identified by 'something' with grant option; 添加一個用戶admin并授權通過本地機(localhost)訪問,密碼"something"。 mysql>grant all privileges on *.* to admin@"%" identified by 'something' with grant option; 添加一個用戶admin并授權可從任何其它主機發(fā)起的訪問(通配符%)。使用這一條語句即可。 2.使用insert語句: mysql>insert into user values('%','admin',password('something'), 'y','y','y','y','y','y', 'y','y','y','y','y','y','y','y') 用戶信息可在mysql數(shù)據(jù)庫中的users表中查看,這里不在介紹了就。數(shù)清y的個數(shù)哦。 好了,使用admin賬號連接試試看,我是屢試屢成功哦,呵呵! 方法三 |
|
|
來自: xue_dong5437 > 《mysql》