I am creating a docker mariadb image and wanted to create a database and user name before bootstrapping mysqld daemon. So as per the documentation I tried below queries.

mysql_embedded -e "CREATE DATABASE IF NOT EXISTS test ;"

mysql_embedded -e "CREATE USER admin@localhost IDENTIFIED BY 'password';"

mysql_embedded -e "select user, host, password, plugin from mysql.user;"

The above query successfully create a database and display user information. But it didn't create the user i.e the middle query didn't get executed. Even it didn't show any error. Can't I create an user using mysql_embedded ?

What is the alternative to mysql_embedded. Is it mysqld --bootstrap ?

Here is a blogpost on mysql_embedded https://mariadb.com/resources/blog/using-mysql_embedded-and-mysqld-bootstrap-to-tinker-with-privilege-tables/

  • mysql_embedded isn't really there for creating users. embedded is when mysql is effectively a shared library for an application. I recommended creating the after bootstrap/mysql_install_db. – danblack Jan 10 at 23:36
  • But from the --help option it seems we can execute any query. – SkyRar Jan 10 at 23:38

As you are using the docker mariadb image the best way is to set the environment variables when running the image:


ref: https://hub.docker.com/_/mariadb/

These will case the database and user to be created with grants (ref)

  • Sorry but I am not using official image. I am creating one from my own using Alpine. However its a general question related to Mariadb only. So let's leave about Docker. – SkyRar Jan 10 at 23:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.