OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
我正在努力学习烧瓶-mysql using this link
但我遇到了某种类型的错误
from flask import Flask
from flaskext.mysql import MySQL
app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASEE_PASSWORD'] = 'root'
app.config['MYSQL_DATABASE_DB'] = 'EmpData'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
@app.route('/')
def index():
return 'hello people'
@app.route("/Authenticate")
def Authenticate():
username = request.args.get('UserName')
password = request.args.get('Password')
cursor = mysql.get_db().cursor()
cursor.execute("SELECT * from User where Username='" + username + "' and Password='" + password + "'")
data = cursor.fetchone()
if data is None:
return "Username or Password is wrong"
else:
return "Logged in successfully"
if __name__ == "__main__":
app.run(debug = True)
帮助我理解这个问题
在终端:
mysql -u root -p
;密码:root
错误在这里 -> app.config['MYSQL_DATABASEE_PASSWORD'] = 'root'
将密钥更正为 app.config['MYSQL_DATABASE_PASSWORD'] = 'root'
,即从 MYSQL_DATABASEE_PASSWORD
.
中删除多余的 E
字符
我正在努力学习烧瓶-mysql using this link 但我遇到了某种类型的错误
from flask import Flask
from flaskext.mysql import MySQL
app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASEE_PASSWORD'] = 'root'
app.config['MYSQL_DATABASE_DB'] = 'EmpData'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
@app.route('/')
def index():
return 'hello people'
@app.route("/Authenticate")
def Authenticate():
username = request.args.get('UserName')
password = request.args.get('Password')
cursor = mysql.get_db().cursor()
cursor.execute("SELECT * from User where Username='" + username + "' and Password='" + password + "'")
data = cursor.fetchone()
if data is None:
return "Username or Password is wrong"
else:
return "Logged in successfully"
if __name__ == "__main__":
app.run(debug = True)
帮助我理解这个问题 在终端: mysql -u root -p ;密码:root
错误在这里 -> app.config['MYSQL_DATABASEE_PASSWORD'] = 'root'
将密钥更正为 app.config['MYSQL_DATABASE_PASSWORD'] = 'root'
,即从 MYSQL_DATABASEE_PASSWORD
.
E
字符