線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1469
推到 Plurk!
推到 Facebook!

Delphi MySQL 用戶問題

答題得分者是:syntax
emilynatiki
一般會員


發表:5
回覆:8
積分:2
註冊:2007-02-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-10-19 23:37:39 IP:202.175.xxx.xxx 訂閱
各位高手, 本人已寫好一個系統但在實行時遇到一些問題:
因為要連到mysql db 的時候在connection有下列setting
server: 192.168.0.1
username:yt
password:123123

但如果我將exe放到ip為192.168.0.11的pc的時候, 便必須到server的mysql中加一個新用戶yt@192.168.0.11
由於ip是自動派的, 如果每次ip都不同, 又要再加用戶方可使用, 那實在太麻煩了, 有沒有其他方法可以解決呢??

而在運行時還遇到另一個問題, 如果正在由其中一個用戶運行, 其他人好像不可以連到db似的....每次都說系統沒有反應....
系統好像只可供一個用戶登入似的.....是不是我在做設定時做錯什麼呢??

感謝各位幫忙!!!!!!!!!!
syntax
尊榮會員


發表:26
回覆:1139
積分:1258
註冊:2002-04-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-10-20 18:51:18 IP:61.64.xxx.xxx 訂閱
我想你沒有仔細學習過 MySQL 喔!
MySQL 的權限管理是階層性的,連線 -> DB -> Table -> Field
並組合 使用帳號、密碼、來源、與權限來管理

你只要設定
1.某帳號,某密碼,某來源 --> 可以連線,最小權限
2.然後再在資料庫(甚至是 Table, Fiels)開放應該有的功能,即可達到「近乎」安全的控管

關於來源的管理,如下:(建議你去 MySQL 抓一份 Reference Manual,提供你的答案,也是由其中複製出來的)
Data from MySQL reference Manual 5.7.5. Access Control, Stage 1: Connection Verification

GRANT ALL PRIVILEGES ON db.* TO david@'192.58.197.0/255.255.255.0';
This allows david to connect from any client host having an IP number client_ip for which the following condition is true:
client_ip & netmask = host_ip
That is, for the GRANT statement just shown:
client_ip & 255.255.255.0 = 192.58.197.0
IP numbers that satisfy this condition and can connect to the MySQL server are those in the range from 192.58.197.0 to 192.58.197.255.
Note: The netmask can only be used to tell the server to use 8, 16, 24, or 32 bits of the address. Examples:
  • 192.0.0.0/255.0.0.0: anything on the 192 class A network
  • 192.168.0.0/255.255.0.0: anything on the 192.168 class B network
  • 192.168.1.0/255.255.255.0: anything on the 192.168.1 class C network
  • 192.168.1.1: only this specific IP
The following netmask (28 bits) will not work:
192.168.0.1/255.255.255.240



The following table shows how various combinations of Host and User values in the user table apply to incoming connections.
Host Value User Value Allowable Connections
'thomas.loc.gov' 'fred' fred, connecting from thomas.loc.gov
'thomas.loc.gov' '' Any user, connecting from thomas.loc.gov
'%' 'fred' fred, connecting from any host
'%' '' Any user, connecting from any host
'%.loc.gov' 'fred' fred, connecting from any host in the loc.gov domain
'x.y.%' 'fred' fred, connecting from x.y.net, x.y.com, x.y.edu, and so on (this is probably not useful)
'144.155.166.177' 'fred' fred, connecting from the host with IP address 144.155.166.177
'144.155.166.%' 'fred' fred, connecting from any host in the 144.155.166 class C subnet
'144.155.166.0/255.255.255.0' 'fred' Same as previous example



===================引 用 emilynatiki 文 章===================
各位高手, 本人已寫好一個系統但在實行時遇到一些問題:
因為要連到mysql db 的時候在connection有下列setting
server: 192.168.0.1
username:yt
password:123123

但如果我將exe放到ip為192.168.0.11的pc的時候, 便必須到server的mysql中加一個新用戶yt@192.168.0.11
由於ip是自動派的, 如果每次ip都不同, 又要再加用戶方可使用, 那實在太麻煩了, 有沒有其他方法可以解決呢??

而在運行時還遇到另一個問題, 如果正在由其中一個用戶運行, 其他人好像不可以連到db似的....每次都說系統沒有反應....
系統好像只可供一個用戶登入似的.....是不是我在做設定時做錯什麼呢??

感謝各位幫忙!!!!!!!!!!
編輯記錄
syntax 重新編輯於 2007-10-20 18:54:34, 註解 無‧
syntax 重新編輯於 2007-10-20 18:59:31, 註解 無‧
syntax 重新編輯於 2007-10-20 19:00:44, 註解 無‧
syntax 重新編輯於 2007-10-20 19:03:12, 註解 無‧
syntax 重新編輯於 2007-10-20 19:03:47, 註解 無‧
syntax 重新編輯於 2007-10-20 19:04:29, 註解 無‧
syntax 重新編輯於 2007-10-20 19:05:54, 註解 無‧
emilynatiki
一般會員


發表:5
回覆:8
積分:2
註冊:2007-02-10

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-10-21 20:59:04 IP:122.100.xxx.xxx 訂閱
 謝謝呀~~~因為一開始就學DELPHI~~其他周邊的軟件都沒有好好學....
經你這樣一說~~我大概知道方向了~~~謝謝哦
系統時間:2024-05-17 14:34:54
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!