I am a newbie to this google App engine. I have written a small python code that was intended to connect the database in google cloud. Unfortunately I am getting this error.
Traceback (most recent call last):
File "/home/revanth/Projects/workspace/project2/connect.py", line 28, in <module>
main()
File "/home/revanth/Projects/workspace/project2/connect.py", line 19, in main
user='revanth'
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)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'revanth'@'76.183.80.171' (using password: NO)")
Here is my code in python
import googleapiclient
import MySQLdb
import os
#from google.storage.speckle.python.api import rdbms_googleapi
def main():
env = os.getenv('SERVER_SOFTWARE')
if (env and env.startswith('Google App Engine/')):
# Connecting from App Engine
db = MySQLdb.connect(
unix_socket='/cloudsql/citric-cistern-97118:geoeq',
user='revanth')
else:
# Connecting from an external network.
# Make sure your network is whitelisted
db = MySQLdb.connect(
host='173.194.232.179',
port=3306,
user='revanth'
)
cursor = db.cursor()
cursor.execute('select * from Whether')
rows = cursor.fetchall()
print rows
if __name__ == '__main__':
main()
Please help me out.
I figured out the solution. I just need to add 0.0.0.0/0 to allow all the external IP address to connect it.
Here is the Link: https://cloud.google.com/sql/docs/access-control
I need to specify the password in the options.