sqlalchemy.exc.OperationalError用户'root'@'<public ip =“”>'访问被拒绝到数据库

时间:2017-07-04 09:51:23

标签: mysql python-3.x google-app-engine installation google-cloud-sql

我完全按照Google cloudsql tutorial的说明操作。但是,当我运行create_tables.py时,我收到以下错误: -

Creating all database tables...
Traceback (most recent call last):
  File "create_tables.py", line 23, in <module>
    db.create_all()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 1007, in create_all
    self._execute_for_all_tables(app, bind, 'create_all')
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 999, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 3934, in create_all
    tables=tables)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1928, in _run_visitor
    with self._optional_conn_ctx_manager(connection) as conn:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1921, in _optional_conn_ctx_manager
    with self.contextual_connect() as conn:
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2112, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2151, in _wrap_pool_connect
    e, dialect, self)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1465, in _handle_dbapi_exception_noconnection
    exc_info
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2147, in _wrap_pool_connect
    return fn()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 387, in connect
    return _ConnectionFairy._checkout(self)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 766, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 516, in checkout
    rec = pool._do_get()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 1138, in _do_get
    self._dec_overflow()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 1135, in _do_get
    return self._create_connection()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 333, in _create_connection
    return _ConnectionRecord(self)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 461, in __init__
    self.__connect(first_connect_check=True)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 651, in __connect
    connection = pool._invoke_creator(self)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 105, in connect
    return dialect.connect(*cargs, **cparams)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 393, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/pymysql/__init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/pymysql/connections.py", line 706, in __init__
    self.connect()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/pymysql/connections.py", line 932, in connect
    self._request_authentication()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/pymysql/connections.py", line 1152, in _request_authentication
    auth_packet = self._read_packet()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/pymysql/connections.py", line 1014, in _read_packet
    packet.check_error()
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/pymysql/connections.py", line 393, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/hell-raiser/temp/python-docs-samples/appengine/flexible/cloudsql/cloudsql/local/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1044, u"Access denied for user 'root'@'43.224.130.174' to database 'gdtmldb'")

在运行上述命令之前,我将SQLALCHEMY_DATABASE_URI设置为mysql+pymysql://root:"<PASSWD1>"@127.0.0.1:3306/gdtmldb

我的app.yaml包含: -

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  python_version: 3

#[START env]
env_variables:
    # Replace user, password, database, and instance connection name with the values obtained
    # when configuring your Cloud SQL instance.
    SQLALCHEMY_DATABASE_URI: >-
      mysql+pymysql://root:<PASSWD1>@/gdtmldb?unix_socket=/cloudsql/greendzine-cloud:asia-east1:gdtmldb
#[END env]

#[START cloudsql_settings]
# Replace project and instance with the values obtained  when configuring your
# Cloud SQL instance.
beta_settings:
    cloud_sql_instances: greendzine-cloud:asia-east1:gdtmldb
#[END cloudsql_settings]

我的项目名称为greendzine-cloud,数据库名称为gdtmldb。我究竟做错了什么?我尝试将SQLALCHEMY_DATABASE_URI中的主机更改为数据库的IP地址,以及localhost和我的公共IP。

0 个答案:

没有答案