Connecting to Google Cloud SQL from App Engine: access denied
<p>Trying to connect to Google Cloud SQL from App Engine. Getting an error 500 and the logs say: "Access denied for user 'root'@'cloudsqlproxy~' (using password: NO)"). The App Engine and cloud SQL are in the same project. The code I use to connect:</p>

<pre><code>class MainPage(webapp2.RequestHandler):

def get(self):

    self.response.headers['Content-Type'] = 'text/plain'

    env = os.getenv('SERVER_SOFTWARE')
    if (env and env.startswith('Google App Engine/')):
        # Connecting from App Engine
        db = MySQLdb.connect(
            unix_socket='/cloudsql/&lt;project-id&gt;:europe-west1:&lt;instance-name&gt;',
            user='root')

    cursor = db.cursor()
    cursor.execute('SELECT 1 + 1')

    self.response.write('pong')

app = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True)
</code></pre>

<p>As I understand, I am doing everything correctly. The code above I effectively copy-pasted a snippet that you can view in Google Dev Console. Everywhere on StackExchange it is said, that I should not pass the password, so I am not doing that either. I have changed root user password when I created the instance. I don't see why would database deny acess to App Engine, they are on the same project! Is there a way to check what are the permissions for the database? </p>

<p>Okay, so turns out there is some misinformation happening. Adding a password parameter solved my issue. But for some reason, there is no mention of this in Google Documentation and many posts on StackOverflow actually directly tell you the oppposite, saying that Cloud SQL will throw an error if you pass it a password when logging in from AppEngine. Maybe some recent update is a cause of this, but in my case, passing a password solved the problem. Hope that helps!</p>

python google-app-engine google-cloud-sql