I use this simple connection script:
import configparser
import mariadb
config = configparser.ConfigParser()
config.read('dbconfig.ini')
config_default = config['DEFAULT']
print(f' mariadb -h {config_default["server"]} -u {config_default["username"]} -p{config_default["password"]} -P {config_default["port"]} {config_default["database"]}')
conn = mariadb.connect(
user=config_default['username'],
password=config_default['password'],
host=config_default['server'],
port=int(config_default['port']),
database=config_default['database']
)
When I run this, I get:
mariadb.OperationalError: Access denied for user 'myuser'@'myhost.local' (using password: YES)
But when I just call the output of the print statement, it connects just fine. So i guess the credentials and everything is correct. For testing I also chose a password without any special characters.
My setup:
- Database: 11.4.4-MariaDB-log
- Python: Python 3.13.1
- Connector: mariadb==1.1.11
- Database client: Ver 15.1 Distrib 10.11.6-MariaDB
I use this simple connection script:
import configparser
import mariadb
config = configparser.ConfigParser()
config.read('dbconfig.ini')
config_default = config['DEFAULT']
print(f' mariadb -h {config_default["server"]} -u {config_default["username"]} -p{config_default["password"]} -P {config_default["port"]} {config_default["database"]}')
conn = mariadb.connect(
user=config_default['username'],
password=config_default['password'],
host=config_default['server'],
port=int(config_default['port']),
database=config_default['database']
)
When I run this, I get:
mariadb.OperationalError: Access denied for user 'myuser'@'myhost.local' (using password: YES)
But when I just call the output of the print statement, it connects just fine. So i guess the credentials and everything is correct. For testing I also chose a password without any special characters.
My setup:
- Database: 11.4.4-MariaDB-log
- Python: Python 3.13.1
- Connector: mariadb==1.1.11
- Database client: Ver 15.1 Distrib 10.11.6-MariaDB
1 Answer
Reset to default 0It was clear that there is some embarrassing reason for this: I used parenthesis for the password in the config file. Python added them to the password, so the password was wrong. When testing on the shell, the shell removed the parenthesis, so the password was correct.