无法对google cloud sql运行manage.py

时间:2016-02-19 10:28:55

标签: python mysql django google-app-engine google-cloud-sql

我正在尝试运行django命令

return 'i' in data.split

在goodle cloud SQL上设置MySQL数据库,但它只针对我的本地开发服务器运行。

我已按照linked StackExchange thread中的代码进行操作。

由于这不起作用,我强制数据库通过在settings.py中定义DATABASE来实现云SQL,我得到以下内容:

manage.py makemigrations
manage.py migrate

我从Google获得了一个IPv4地址,当我连接MySQL Workbench时,用户/密码可以访问

编辑 - 下面我附上了settings.py

Traceback (most recent call last):
  File "C:\FCA\manage.py", line 24, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 398, in execute
    self.check()
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Python27\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Python27\lib\site-packages\django\core\checks\model_checks.py", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File "C:\Python27\lib\site-packages\django\db\models\base.py", line 1170, in check
    errors.extend(cls._check_fields(**kwargs))
  File "C:\Python27\lib\site-packages\django\db\models\base.py", line 1247, in _check_fields
    errors.extend(field.check(**kwargs))
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line 925, in check
    errors = super(AutoField, self).check(**kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line 208, in check
    errors.extend(self._check_backend_specific_checks(**kwargs))
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line 317, in _check_backend_specific_checks
    return connections[db].validation.check_field(self, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\validation.py", line 18, in check_field
    field_type = field.db_type(connection)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line 625, in db_type
    return connection.data_types[self.get_internal_type()] % data
  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 36, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 184, in data_types
    if self.features.supports_microsecond_precision:
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\features.py", line 53, in supports_microsecond_precision
    return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5)
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 359, in mysql_version
    with self.temporary_connection():
  File "C:\Python27\lib\contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "C:\Python27\lib\site-packages\django\db\backends\base\base.py", line 564, in temporary_connection
    cursor = self.cursor()
  File "C:\Python27\lib\site-packages\django\db\backends\base\base.py", line 231, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "C:\Python27\lib\site-packages\django\db\backends\base\base.py", line 204, in _cursor
    self.ensure_connection()
  File "C:\Python27\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection
    self.connect()
  File "C:\Python27\lib\site-packages\django\db\utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Python27\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection
    self.connect()
  File "C:\Python27\lib\site-packages\django\db\backends\base\base.py", line 171, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 264, in get_new_connection
    conn = Database.connect(**conn_params)
  File "build\bdist.win-amd64\egg\MySQLdb\__init__.py", line 81, in Connect
  File "build\bdist.win-amd64\egg\MySQLdb\connections.py", line 193, in __init__
django.db.utils.OperationalError: (1045, "Access denied for user 'thwaites'@'localhost' (using password: YES)")

1 个答案:

答案 0 :(得分:0)

我最后通过从开发服务器导出我的数据库结构并将其导入CloudSQL来临时对其进行排序,这在网站不活动时很好但如果我想更新实时网站并保持不变将成为问题我的数据!