Unable to get WordPress, Mariadb working with Docker

[ad_1]

I’m trying to make WordPress and MariaDB working with docker. But I get “Error establishing a database connection” error.

This my docker command to get MariaDB up and running:
`docker run –name mariadb -v /opt/mariadb/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=testpass -d mariadb`

Then I create a new database user by:

“`
ROOT_DB_PASS=”testpass”
DB_NAME=”wpdocker”
DB_USER=”dockeruser”
DB_PASSWORD=”dbpass”

cat <<EOF | docker exec –interactive mariadb bash
mysql -uroot -p${ROOT_DB_PASS} <<_EOF_
CREATE DATABASE ${DB_NAME};
CREATE USER ‘${DB_USER}’@’localhost’ IDENTIFIED BY ‘${DB_PASSWORD}’;
GRANT ALL ON ${DB_NAME}.* TO ‘${DB_USER}’@’localhost’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
_EOF_
EOF
“`

Finally, create WordPress container by:

“`
docker run -d –name wordpress \
–restart unless-stopped \
–link mariadb:mysql \
-e WORDPRESS_DB_HOST=mysql \
-e WORDPRESS_DB_NAME=”$DB_NAME” \
-e WORDPRESS_DB_USER=”$DB_USER” \
-e WORDPRESS_DB_PASSWORD=”$DB_PASSWORD” \
-e WORDPRESS_INSTALL_TYPE=”blog” \
-e WORDPRESS_EMAIL=”[email protected]” \
-e WORDPRESS_SITE_TITLE=”MySite” \
-e WORDPRESS_ADMIN_USER=”exampleuser” \
-e WORDPRESS_ADMIN_PASSWORD=”examplepass” \
-e WORDPRESS_CONFIG_EXTRA=”define(‘WP_SITEURL’,’http://example.com’); define(‘WP_HOME’,’http://example.com’); define(‘WP_INSTALLING’, true);” \
-e WORDPRESS_INSTALL_PLUGINS=”akismet,jetpack” \
-p 53880:80 \
-v /opt/wordpress/sites/example.com/:/var/www/html/ \
wordpress
“`

I’m able to login to the MariaDB manually with the username/password, but the mariaDB docker logs says:

…..
…..
2023-01-01 6:35:52 0 [Warning] You need to use –log-bin to make –expire-logs-days or –binlog-expire-logs-seconds work.
2023-01-01 6:35:52 0 [Note] InnoDB: Buffer pool(s) load completed at 230101 6:35:52
2023-01-01 6:35:52 0 [Note] Server socket created on IP: ‘0.0.0.0’.
2023-01-01 6:35:52 0 [Note] Server socket created on IP: ‘::’.
2023-01-01 6:35:52 0 [Note] mariadbd: ready for connections.
Version: ‘10.10.2-MariaDB-1:10.10.2+maria~ubu2204’ socket: ‘/run/mysqld/mysqld.sock’ port: 3306 mariadb.org binary distribution
2023-01-01 6:35:58 3 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:35:58 4 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:35:59 5 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:35:59 6 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:35:59 7 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:36:00 8 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:44:31 9 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:44:32 10 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:49:09 11 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
2023-01-01 6:49:09 12 [Warning] Access denied for user ‘dockeruser’@’172.17.0.3’ (using password: YES)
….
….

What am I doing wrong?

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer