与mysql的python db连接

时间:2015-10-03 08:39:35

标签: python mysql

我正在使用sql workbench,用于数据库连接的工作台工具中的php代码是:

$host="215.157.120.106";
$port=3386;
$socket="";
$user="root";
$password="";
$dbname="pay";

$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
    or die ('Could not connect to the database server' . mysqli_connect_error());

//$con->close();

我想在python中查询。 我的尝试:

import MySQLdb
db = MySQLdb.connect(host="215.157.120.106",user="root",db="pay",port=3386,passwd="")

但它给出了错误:

OperationalError: (1045, "Access denied for user 'root'@'16.95.57.211' (using password: NO)")

0 个答案:

没有答案