lesson Do280:
Why when use the following command line can create any username and passwd in mysql container?
# oc new-app --name=mysqldb \
--docker-image=workstation.lab.example.com:5000/rhscl/mysql-57-rhel7 \
--insecure-registry \
-e MYSQL_USER=ose \
-e MYSQL_PASSWORD=openshift \
-e MYSQL_DATABASE=quotes
Can you look into below, if any prob reply me
version: '3'services: database: image: mysql:5.6 volumes: - dbdata:/var/lib/mysql environment: - "MYSQL_DATABASE=my_database_name" - "MYSQL_USER=my_database_user" - "MYSQL_PASSWORD=my_database_password" - "MYSQL_ROOT_PASSWORD=my_root_password" ports: - "33061:3306"
But I keep getting this error.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Have you face same issue
Please Reply me ASAP
Thanks
Nikhil John
Its could be the issue of grant access, Please login to container and try to grant access to root
CREATE USER username WITH SYSID uid | CREATEDB | NOCREATEDB | CREATEUSER | NOCREATEUSER | IN GROUP groupname [, ...] | [ ENCRYPTED | UNENCRYPTED ]PASSWORD 'password' | VALID UNTIL 'time'
Hey, @Jacob, @nikjohn1538,
Both of you are failing to specify some important information in your questions.
@Jacob, How exactly do you create the user accounts? What commands do you use and how do you verify the new users are able to log in?
@nikjohn1538, What is the output you are quoting in your question? How did you obtain that? Also, I see you are using the Docker hub MySQL image - do mind that image works differently from RHSCL MySQL images we mostly use in our courses.
Cheers,
Grega
If I remember that template properly, I think if u do a --param=<variable>=<value> you will end up with a mysql container with the intended variables & values.
Create a user name and password
My SQL is the world's popular open-source Database in its performance, Readability, and User Experience.
For more information about SQL Open www.sql.com or Oracle SOA
Example stack.yml for MySQL:
# Use root/example as user/password credentials version: '3.1' services: db: image: mysql command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_PASSWORD: example
If I understand your question correctly, the question is about why environmental variables MYSQL_USER, MYSQL_PASSWORD and MYSQL_DATABASE cause the container to create a user with respective value in mysql.
To understand why, let's explore the Dockerfile...
ENTRYPOINT ["container-entrypoint"] CMD ["run-mysqld"]
You can see that when we start the container, the script container-entrypoint is executed. This script execs the arguments specified in CMD which is run-mysqld script.
The script run-mysqld checks whether $MYSQL_DATADIR/mysql exists, otherwise it will execute a function initialize_database as per ...
if [ ! -d "$MYSQL_DATADIR/mysql" ]; then initialize_database "$@" else start_local_mysql "$@" fi
Function initialize_database is defined in common.sh. If $MYSQL_USER is defined, it creates that user with $MYSQL_PASSWORD as per this code excerpt.
if [ -v MYSQL_USER ]; then log_info "Creating user specified by MYSQL_USER (${MYSQL_USER}) ..." mysql $mysql_flags <<EOSQL CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}'; EOSQL fi
The function also creates the database specified by $MYSQL_DATABASE.
I hope this answers your question.
Hello
This command creates a new MySQL container and sets up a user, password, and database.
Thank you .
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.