Reputation: 5513
Can't connect to db.
Username and password is correct. I've tried several combinations. I've verified my SQLALCHEMY_DATABASE_URI
using 'mysql://user:pass@localhost:8889/db-name'
but cannot connect. I can connect without issue using mysql command line utility. I've even tried using a username without a password to no avail.
Flask App Details - config.py
import os
basedir = os.path.abspath(os.path.dirname(__file__))
CSRF_ENABLED = True
SQLALCHEMY_DATABASE_URI = 'mysql://datadmin:password@localhost:8889/db-name'
WHOOSH_BASE = os.path.join(basedir, 'whoosh')
_init_.py
import os
from flask import Flask, render_template, jsonify, request
from flask.ext.sqlalchemy import SQLAlchemy
from config import basedir
app=Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
from app import views, models
Stacktrace
File ".../site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (OperationalError) (1045, "Access denied for user 'datadmin'@'localhost' (using password: YES)") None None
Connecting via Command Line
user@hostname:~$ mysql -u datadmin -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.29 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Anybody have any tips or know how I can figure out what's wrong?
Upvotes: 2
Views: 3074
Reputation: 67479
On your Flask app you are connecting through port 8889.
On the mysql command line, however, you seem to be using default options, which in a stock mysql build would connect to port 3306.
Could you be running two mysql servers on these two ports, each with different user permissions?
Upvotes: 2