Linux – Docker MySQL Image – CREATE MYSQL_USER

I am new to docker containers, and I am working on automating some MySQL tasks. By using bash scripts I am able to automate the creation and dump of Databases but now i am trying to create the new user getting input from the command line and it is not working. this is my script:

sudo docker run -it --link testing1:mysql --rm mysql/mysql-server:5.7.11 sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -e"CREATE USER 'docker'@'%' IDENTIFIED BY 'tester'"'

the error message i receive is :

  • A particular image is not getting pulled from Docker Hub - jwilder/nginx-proxy
  • link command hangs when linking container to itself
  • Can't expose a fuse based volume to a Docker container
  • npm update failed in docker
  • Issue linking containers in Docker using Docker-compose
  • Dokku on Ubuntu refusing connection
    + E_BADARGS=65
    ++ which mysql
    + MYSQL=/usr/bin/mysql
    + sudo docker run -it --link testing1:mysql --rm mysql/mysql-server:5.7.11 sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"
    -e"CREATE USER docker@% IDENTIFIED BY tester"'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '% IDENTIFIED BY tester' at line 1

  • Move Docker Containers via export/import: lost Configuration like start command
  • docker-compose build throwing error ERROR: Untar re-exec error: signal: killed: output:
  • docker container started in Detached mode stopped after process execution
  • Accessing Website running in Kubernetes Which is Running on Virtualbox from Host OS
  • Nancy on Linux is using 100% CPU
  • Moving location of dockerized GitLab data volumes
  • 3 Solutions collect form web for “Linux – Docker MySQL Image – CREATE MYSQL_USER”

    You need to enclose the % (to allow connections from any ip) in quotations.

    CREATE USER docker@'%' IDENTIFIED BY tester

    You can use this image as a template.

    I used
    mysql -e'GRANT ALL ON *.* TO user@"%" IDENTIFIED BY "password";'

    The solution was to set the ENV variables to get the user input like like this:
     and then this:     docker exec -it ctb /usr/bin/mysql -h -uroot -pmario123 -e "GRANT USAGE ON *.* TO ${USER}@${SOURCE} IDENTIFIED BY ${PASSWORD};"
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.