简体   繁体   English

sqlalchemy.exc.OperationalError:(MySQLdb._exceptions.OperationalError)(1045,“用户'taran'@'localhost'的访问被拒绝(使用密码:是)”)

[英]sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, "Access denied for user 'taran'@'localhost' (using password: YES)")

I have started this today and received this over again and again and I have recreated the user also but it is not working.我今天开始这个并一次又一次地收到这个,我也重新创建了用户,但它不起作用。 Please help me to debug it.请帮我调试一下。

This is my app.py这是我的应用程序.py

 from flask import Flask, jsonify, render_template, request from flask_sqlalchemy import SQLAlchemy from datetime import datetime app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://taran:1234@localhost/flask' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(app) class Post(db.Model): id = db.Column(db.Integer, primary_key = True) title = db.Column(db.String(50), nullable = False) body = db.Column(db.String(200), nullable = False) date = db.Column(db.DateTime(timezone=True), default=datetime.now()) @app.route('/', methods = ['GET', 'POST']) def home(): title = request.form.get('title') body = request.form.get('body') post = Post(title = title, body = body) db.session.add(post) db.session.commit() return render_template('index.html') if __name__ == "__main__": app.run(debug= True)
This is the error coming 这是错误来了 在此处输入图像描述

Please help请帮忙

check if the password to access your SQL database is correct or else try changing your SQL root password to something else and try again.检查访问 SQL 数据库的密码是否正确,或者尝试将 SQL 根密码更改为其他密码,然后重试。 The above error is very similar to the one we commonly encounter while logging on to a website with the wrong password or username.上述错误与我们在使用错误的密码或用户名登录网站时经常遇到的错误非常相似。

for changing the root password see the below video https://youtu.be/izMuHGwXyjQ如需更改 root 密码,请参阅以下视频https://youtu.be/izMuHGwXyjQ

If you don't have a password try either of this如果您没有密码,请尝试其中任何一个

Option 01:选项 01:

SQLALCHEMY_DB_URI='mysql://root@localhost:<PORT>/<DB NAME>'

Option 02:选项 02:

SQLALCHEMY_DB_URI='mysql://root:''@localhost:<PORT>/<DB NAME>'

Have you tried to change the driver?您是否尝试过更改驱动程序?

#from
'mysql://taran:1234@localhost/flask' 
#to 
'mysql+pymysql://taran:1234@localhost/flask' 

(I assume you've checked credentials already) (我假设您已经检查过凭据)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 sqlalchemy.exc.OperationalError:(MySQLdb._exceptions.OperationalError)(1045,“用户&#39;root&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:NO)”) - sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, “Access denied for user 'root'@'localhost' (using password: NO)”) MySQLdb._exceptions.OperationalError OperationalError:(1045,“用户&#39;root&#39;@&#39;localhost&#39;的访问被拒绝(使用密码:是)”) - MySQLdb._exceptions.OperationalError OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)") MySQLdb._exceptions.OperationalError:(1698,“用户'root'@'localhost'的访问被拒绝”) - MySQLdb._exceptions.OperationalError: (1698, "Access denied for user 'root'@'localhost'") OperationalError:(1045,“拒绝用户&#39;root&#39;@&#39;localhost&#39;的访问(使用密码:是)”) - OperationalError: (1045, “Access denied for user 'root'@'localhost' (using password: YES)”) sqlalchemy.exc.OperationalError:(MySQLdb._exceptions.OperationalError)(1054,“'字段列表'中的未知列'detail.id'”) - sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1054, "Unknown column 'detail.id' in 'field list'") Django OperationalError,位于/(1045,“拒绝用户&#39;root&#39;@&#39;localhost&#39;的访问(使用密码:是)”) - Django OperationalError at / (1045, “Access denied for user 'root'@'localhost' (using password: YES)”) sqlalchemy OperationalError: (OperationalError) (1045, "Access denied for user - sqlalchemy OperationalError: (OperationalError) (1045, "Access denied for user OperationalError: (1045, “用户 &#39;rajendra&#39;@&#39;localhost&#39; 的访问被拒绝(使用密码:NO)”) - OperationalError: (1045, "Access denied for user 'rajendra'@'localhost' (using password: NO)") OperationalError:(1045,“拒绝用户&#39;root&#39;@&#39;localhost&#39;的访问(使用密码:NO)”) - OperationalError: (1045, “Access denied for user 'root'@'localhost' (using password: NO)”) Python/Masonite:pymysql.err.OperationalError(1045,“用户 'root'@'172.18.0.1' 的访问被拒绝(使用密码:YES)”) - Python/Masonite: pymysql.err.OperationalError (1045, "Access denied for user 'root'@'172.18.0.1' (using password: YES)")
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM