[問題] cgi上面 import MySQLdb 無法成功,但是直接執行正常

看板Python作者 (小判)時間16年前 (2009/07/04 19:44), 編輯推噓1(103)
留言4則, 4人參與, 最新討論串1/1
我寫了下面這隻python程式要來獲得MySQL裡面的資料 #!/usr/bin/python #coding:utf-8 import MySQLdb conn = MySQLdb.connect(host="x.x.x.x",user="xx",passwd="xx",db="xx") cursor = conn.cursor() cursor.execute("select * from rule") result = cursor.fetchall() print "Content-Type: text/html" # HTML is following print # blank line, end of headers print "<html>" print "<head>" print "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" print "<title> Python import MySQLdb</title>" print "</head>" print "<body>" for record in result: print record[0] print "</body>" 如果我直接在 console 裡面 python sql.py的話可以正確獲得資料 但是放到網站上面想要作成cgi來用的時候就會出現 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log 錯誤訊息蠻多的,我貼在這邊。 http://sites.google.com/site/iwhiori/home/python-mysqldb-error 總而言之我想要用 python 在網頁上面讀取資料庫資料 咕狗了超過八個小時!!還是找不到答案... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.174.37.8

07/04 20:27, , 1F
錯誤訊息不是說了沒有權限存取檔案夾:/nonexistent?
07/04 20:27, 1F

07/05 01:30, , 2F
你有權限execute和讀DB,user of CGI沒有...
07/05 01:30, 2F

07/05 01:36, , 3F
那誰是use of CGI ?
07/05 01:36, 3F

07/05 10:48, , 4F
通常是apache...
07/05 10:48, 4F
文章代碼(AID): #1AJq2MwB (Python)
文章代碼(AID): #1AJq2MwB (Python)