我正在尝试在运行 12.04 的 Ubuntu 机器上使用 mysql 创建一个远程数据库。
它有一个启用远程登录的root用户。我已经启动了服务器。
的输出
sudo netstat -tap | grep mysql
节目
tcp 0 0 *:mysql *:* LISTEN 13135/mysqld
从也运行 Ubuntu 12.04 的客户端计算机上,我使用 python 脚本使用 sqlalchemy 连接到远程 mysql 数据库。
from pox.core import core
import pox.openflow.libopenflow_01 as of
import re
import datetime
import time
from sqlalchemy import create_engine, ForeignKey
from sqlalchemy import Column, Date, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql.expression import exists
log = core.getLogger()
engine = create_engine('mysql://root:pass@192.168.129.139/home/karthik.sharma/ms_thesis/nwtopology.db', echo=False)
Base = declarative_base()
Session = sessionmaker(bind=engine)
session = Session()
class SourcetoPort(Base):
""""""
__tablename__ = 'source_to_port'
id = Column(Integer, primary_key=True)
port_no = Column(Integer)
src_address = Column(String,index=True)
#-----------------------------------------
def __init__(self, src_address,port_no):
""""""
self.src_address = src_address
self.port_no = port_no
create_engine() 调用失败并出现以下错误。
return dialect.connect(*cargs, **cparams)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 280, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (OperationalError) (1045, "Access denied for user 'root'@'openflow.ems.com' (using password: YES)") None None
我无法弄清楚为什么会这样?非常感谢任何帮助?