0
good afternoon, I was doing some tests and I decided to try using python3 to manipulate databases but I can never connect with the database with python because the same error always happens:
mysql.connector.errors.ProgrammingError: 1698 (28000): Access denied for user 'root'@'localhost'
I did the complete installation of mariadb with the command
sudo_mysql_secure_installation
I don’t know if I need any more commands or do anything else.
The code I used to connect to python3 is as follows:
import mysql.connector
mydb=mysql.connector.connect(host="localhost",database="testes",user="root",passwd="hugo")
print(mydb)
Make sure that the password is correct and that the basis "tests" actually exists (I don’t know if this would cause a denied access, but it’s good to check).
– Jéf Bueno
yes there is such a database
– Hugo Barbosa
This has nothing to do with Python, the error is that you did not authorize a "root" user with "Ugo" password to access the DB by the "localhost" path. You need to check and fix this directly with the DB tools, test access with these tools, making sure it works, then use it in Python.
– Bacco