无法连接到数据库。
用户名和密码正确。我尝试了几种组合。我已经验证了我的SQLALCHEMY_DATABASE_URI
使用'mysql://user:pass@localhost:8889/db-name'
但无法连接。我可以使用 mysql 命令行实用程序毫无问题地连接。我什至尝试使用没有密码的用户名无济于事。
烧瓶应用程序详细信息 - 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')
_初始化_.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
堆栈跟踪
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
通过命令行连接
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>
任何人都有任何提示或知道我如何找出问题所在?