If you want to give a specific user access from all machines in a given domain (for example, mydomain.com), you can issue a GRANT statement that uses the ‘%' wildcard character in the host part of the account name:
譯文:如果需要讓特定的用戶從給定域(例如mydomain.com)的所有計算機上訪問 MySQL 服務器,你可以執行在賬戶名的 host 部分使用了通配符“%” 的 GRANT 語句
mysql> GRANT ...
-> ON *.*
-> TO 'myname'@'%.mydomain.com'
-> IDENTIFIED BY 'mypass';
To do the same thing by modifying the grant tables directly, do this:
譯文:也可以使用直接修改授權表的方式來實現:
mysql> INSERT INTO user (Host,User,Password,...)
-> VALUES('%.mydomain.com','myname',PASSWORD('mypass'),...);
mysql> FLUSH PRIVILEGES;
再來解決問題:
一、允許用戶 wp 從 192.168.2.98 登錄 MySQL 服務器(下面的實例均為登錄服務器192.168.2.28)
(1)先在MySQL中授權:grant select,update,insert,delete on mysql.* to 'wp'@'192.168.2.98' identified by '123';
(2)再用VFP連接:SQLSTRINGCONNECT("driver={mysql odbc 3.51 driver};server=192.168.2.28;uid=wp;pwd=123;port=3306;")
如果有多個網址,分別執行授權就可以了。
二、允許用戶 wp 從某個網段登錄 MySQL 服務器
(1)先在MySQL中授權:grant select,update,insert,delete on mysql.* to 'wp'@'192.168.2.%' identified by '123';
(2)再用VFP連接:SQLSTRINGCONNECT("driver={mysql odbc 3.51 driver};server=192.168.2.28;uid=wp;pwd=123;port=3306;")
三、允許用戶 wp 從任何網址登錄 MySQL 服務器
(1)先在MySQL中授權:grant select,update,insert,delete on mysql.* to 'wp'@'%' identified by '123';
(2)再用VFP連接:SQLSTRINGCONNECT("driver={mysql odbc 3.51 driver};server=192.168.2.28;uid=wp;pwd=123;port=3306;")