Score:0

Docker MariaDB ERROR 1045 (28000)

py flag

I saw many questions on this topic but it doesn't work for me.
I got this error while connecting on the DB with user root.
Here is my mariadb configuration from docker:

docker run -d \ --name=mariadb \ -e PUID=1002 \ -e PGID=1002 \ -e MYSQL_ROOT_PASSWORD=ROOT_ACCESS_PASSWORD \ or -e MYSQL_ROOT_PASSWORD=password -e TZ=Europe/London \ -p 3306:3306 \ -v /media/RAID250/DockerConfigs/MariaDB:/config \ --restart unless-stopped \ lscr.io/linuxserver/mariadb:latest

I tried to setup manually the password but still not working.
I tried to delete all files in this folder /media/RAID250/DockerConfigs/MariaDB to make a fresh install of mariadb... no effect.
I tried to stop the mariadb services but none cmd line works.
I also tried mariadb-secure-installation once I'm in the container after this cmd line: docker exec -it mariadb bash:

root@c7afe65d1643:/# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Thank you in advance.

Score:2
vn flag

I believe you've made yourself the victim of an "insurmountable one-liner" by running the command in a single long line.

Let's try and break your command down, line by line:

docker run -d \
 --name=mariadb \
 -e PUID=1002 \
 -e PGID=1002 \
 -e MYSQL_ROOT_PASSWORD=ROOT_ACCESS_PASSWORD \
 or -e MYSQL_ROOT_PASSWORD=password \
 -e TZ=Europe/London \
 -p 3306:3306 \
 -v /media/RAID250/DockerConfigs/MariaDB:/config \
 --restart unless-stopped \
 lscr.io/linuxserver/mariadb:latest

Now it's pretty easy to spot the error - you're defining the variable MYSQL_ROOT_PASSWORD two times - and in addition it's difficult to decipher what the sudden or (which is most likely an instruction comment) is doing to the command.

This shows why it's a good idea to create an easily manageable startup script for your containers. You could create the script docker_mariadb.sh:

#!/bin/bash

docker run -d \
  --name=mariadb \
  -e PUID=1002 \
  -e PGID=1002 \
  -e MYSQL_ROOT_PASSWORD=<the-one-and-only-true-password-here> \
  -e TZ=Europe/London \
  -p 3306:3306 \
  -v /media/RAID250/DockerConfigs/MariaDB:/config \
  --restart unless-stopped \
  lscr.io/linuxserver/mariadb:latest

Make the script executable:

chmod +x ./docker_mariadb.sh

Now you can just run ./docker_mariadb.sh to start the container, and you have documented your startup configuration for the container as well.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.