python
1#!/usr/bin/python 2# coding:utf-8 3 4def show_fieldname(): 5 try: 6 import mysql.connector 7 connect = mysql.connector.connect(user='root', password='spass', host='localhost', database='hoge', charset='utf8') 8 cursor = connect.cursor() 9 sql = "show columns from finance_data;" 10 cursor.execute(sql) 11 # connect.commit() 12 result = cursor.fetchall() 13 for i in result: 14 print(i) 15 return result 16 cursor.close() 17 connect.close() 18 except Exception as e: 19 print(e) 20 21 22import cgitb 23cgitb.enable(display=1, logdir=None, context=5, format="html") 24print "Content-Type: text/html\n"; #これをつけると直接ブラウザに結果表示 25 26show_fieldname() 27
これをクライアント側からPOSTで実行しますと
2003: Can't connect to MySQL server on 'localhost:3306' (13 Permission denied)
と怒られます。誰にアクセス権がないのかわかりまえん。どなたか対処法をおしえていただきたいでです。なお、クライアント側はMacOS10.10,サーバ側はCentOS6.5です。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/20 10:25