mysql Access denied for user root@localhost (using password: NO) despite having set a password and entered it in connection uri

I'm trying to configure a mysql db with pymysql and Flask-sqlalchemy in a flask app. db = SQLAlchemy() app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:password@localhost:3306/ftm' db.