Create a quick testing mysql database

Submitted by code_admin on Wed, 07/25/2018 - 10:37
  1. docker run -d -p 3306:3306 --name quick_db -e MYSQL_ROOT_PASSWORD=PASSWORD123 -h quick_db --network="bridge" mysql

Give some time between these steps to allow the DB to start up

  1. docker exec -it quick_db /bin/bash -c 'mysql -uroot -pPASSWORD123'

Steps to create a test user:

  1. DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
  2. FLUSH PRIVILEGES;
  3. CREATE DATABASE test_db CHARACTER SET utf8 COLLATE utf8_general_ci;
  4. CREATE USER userName@'%' IDENTIFIED BY 'tmp_pass';
  5. GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON userName.* TO 'tbhushan'@'%';
  6.  
  7. SELECT default_character_set_name, schema_name FROM information_schema.SCHEMATA;

Tags

RJM Article Type
Work Notes