首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在Google CloudSQL OperationalError 1045上运行syncdb,使用密码拒绝用户'root'@'localhost‘的访问:否

无法在Google CloudSQL OperationalError 1045上运行syncdb,使用密码拒绝用户'root'@'localhost‘的访问:否
EN

Stack Overflow用户
提问于 2014-08-19 10:23:37
回答 1查看 695关注 0票数 0

基于下面的google文档教程,我有以下设置。

我从来没有谷歌提示我的oauth令牌url。这应该符合他们的文件。我不知道到底出了什么问题。

可能有人可以尝试使用syncdb上的--traceback选项和-v 3,并告诉我在使用syncdb时调用了哪些路径和库。https://accounts.google.com/o/oauth2/auth.

这是我试图使用syncdb连接的错误。

代码语言:javascript
复制
$ SETTINGS_MODE='prod' python manage.py  syncdb -v 3 --traceback  
Traceback (most recent call last):  
  File "/home/user/bin/lib/google_appengine/lib/django-1.5/django/core/management/base.py", line 222, in run_from_argv  
    self.execute(*args, **options.__dict__)  
  File "/home/user/bin/lib/google_appengine/lib/django-1.5/django/core/management/base.py", line 255, in execute  
    output = self.handle(*args, **options)  
  File "/home/user/bin/lib/google_appengine/lib/django-1.5/django/core/management/base.py", line 385, in handle  
    return self.handle_noargs(**options)  
  File "/home/user/bin/lib/google_appengine/lib/django-1.5/django/core/management/commands/syncdb.py", line 56, in handle_noargs  
    cursor = connection.cursor()  
  File "/home/user/bin/lib/google_appengine/lib/django-1.5/django/db/backends/__init__.py", line 324, in cursor  
    cursor = self.make_debug_cursor(self._cursor())  
  File "/home/user/bin/lib/google_appengine/lib/django-1.5/django/db/backends/mysql/base.py", line 406, in _cursor  
    self.connection = Database.connect(**kwargs)  
  File "/home/user/projects/my-app/src/my-app/local/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect  
    return Connection(*args, **kwargs)  
  File "/home/user/projects/my-app/src/my-app/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__  
    super(Connection, self).__init__(*args, **kwargs2)  
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")  

当我尝试使用django的特定版本时,会附带GAE,并使用manage.py提供的设置设置路径。我也犯了同样的错误。

代码语言:javascript
复制
SETTINGS_MODE='prod' python ../lib/google_appengine/lib/django-1.5/django/bin/django- admin.py  syncdb -v 3 --traceback --settings=opexdash.settings --pythonpath=. 

然而,我可以在没有任何问题的情况下使用dbshell。

代码语言:javascript
复制
$ SETTINGS_MODE='prod' python manage.py dbshell  
Reading table information for completion of table and column names  
You can turn off this feature to get a quicker startup with -A  

Welcome to the MySQL monitor.  Commands end with ; or \g.  
Your MySQL connection id is 54  
Server version: 5.5.39 (Google)  

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.  

Oracle is a registered trademark of Oracle Corporation and/or its  
affiliates. Other names may be trademarks of their respective  
owners.  

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  

mysql> select @@hostname;  
+------------+  
| @@hostname |  
+------------+  
| localhost  |  
+------------+  
1 row in set (0.40 sec)  

mysql> select database();  
+------------+  
| database() |  
+------------+  
| my_db      |  
+------------+  
1 row in set (0.32 sec)  

以下是我根据文档使用的其他设置。

代码语言:javascript
复制
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'):  
    # Running on production App Engine, so use a Google Cloud SQL database.  
    DATABASES = {  
        'default': {  
            'ENGINE': 'django.db.backends.mysql',  
            'HOST': '/cloudsql/nth-hybrid-672:beta-dash02',  
            'NAME': 'my-app',  
            'USER': 'root',  
        }  
    }  
elif os.getenv('SETTINGS_MODE') == 'prod':  
    # Running in development, but want to access the Google Cloud SQL instance  
    # in production.  
    DATABASES = {  
        'default': {  
            #'ENGINE': 'google.appengine.ext.django.backends.rdbms',  
            'ENGINE': 'django.db.backends.mysql',  
            'INSTANCE': 'your-project-id:your-instance-name',  
            'NAME': 'my-app',  
            'USER': 'root',  
            #'HOST': '173.100.100.100',  I can synkdb using it this way with a password set, ip address has been changed for this public forum
            #'PASSWORD' : ''  
        }  
    }  
else:  
    # Running in development, so use a local MySQL database.  
    DATABASES = {  
        'default': {  
            'ENGINE': 'django.db.backends.mysql',  
            'NAME': 'gae',  
            'USER': 'gae',  
            'PASSWORD': 'gae',  
        }  
    }   

我认为问题很可能是我的道路,环境设置。但是,我希望当我在GAE/lib目录中使用完整的管理路径时,它应该能够工作。

代码语言:javascript
复制
$PATH
/home/user/projects/my-app/src/my-app/bin:   
/usr/local/sbin:  
/usr/local/bin:  
/usr/sbin:  
/usr/bin:   
/sbin:  
/bin:  
/usr/games:  
/usr/local/games:  
/usr/lib/jvm/default-java:  
/usr/share/javadb/bin:  
/home/user/bin:  
/home/user/bin/lib/google_appengine/:  
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-19 11:39:13

您不需要oauth,而是连接到数据库,就好像它是一个普通的远程MySQL实例一样;因此,您需要

代码语言:javascript
复制
'ENGINE': 'django.db.backends.mysql',  
'NAME': 'my-app',  # your DB name
'USER': 'root',  
'HOST': '173.xxx.xxx.xxx',  # your instance's IP address
'PASSWORD' : 'your-root-password-here',

(假设您允许自己的IP连接到实例。)您还可以设置连接以遍历SSL。

谷歌的文档已经过时,但这篇文章来自工程师并断言,推荐的连接方式是将MySQL实例作为正常的远程服务器。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25381024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档