cancel
Showing results for 
Search instead for 
Did you mean: 
Jacob
Cadet
Cadet
  • 5,335 Views

Do280 mysql container user and password

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

Labels (1)
8 Replies
  • 5,287 Views

@Jacob

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

oracle IT/DBM Admin

AshutoshBhakare
Mission Specialist
Mission Specialist
  • 5,245 Views

Its could be the issue of grant access, Please login to container and try to grant access to root 

0 Kudos
gautham
Cadet
Cadet
  • 4,758 Views

CREATE USER username  WITH SYSID uid   | CREATEDB | NOCREATEDB 
| CREATEUSER | NOCREATEUSER  | IN GROUP groupname [, ...] | 
[ ENCRYPTED | UNENCRYPTED ]PASSWORD 'password' | VALID UNTIL 'time' 

 sql/pl sql 

0 Kudos
oldbenko
Moderator
Moderator
  • 5,201 Views

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

A black cat crossing the street signifies that the animal is going somewhere.
[don't forget to kudo a helpful post or mark it as a solution!]
Radesh
Flight Engineer Flight Engineer
Flight Engineer
  • 5,195 Views

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.

  • 4,283 Views

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

 

https://smconsultant.com/
ekc
Mission Specialist
Mission Specialist
  • 4,269 Views

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.

stevediaz
Mission Specialist
Mission Specialist
  • 2,009 Views

Hello

This command creates a new MySQL container and sets up a user, password, and database.

Thank you .

Join the discussion
You must log in to join this conversation.