MySQL local & docker
docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD="1234" -d mysql:5.6
# In docker
docker exec -it mysql mysql -u root -p
Enter password:
https://hub.docker.com/_/mysql
Create DataBase & Create User
# In local
mysql -u root -p
Enter password:
mysql> CREATE DATABASE board;
— Creaet board DataBase
mysql> CREATE USER 'aduser' IDENTIFIED BY 'aduser_password';
— Create aduser user with password
mysql> grant all on board.*to 'aduser';
- grant all permission to aduser for board DB
Show all Databases in MySQL
mysql> show databases;
Show all users in MySQL
mysql> select user from mysql.user;
Use board database
mysql> use board
Database changed
Create table with table name users
mysql> CREATE TABLE users(id int(11) NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, salary float(10) DEFAULT NULL, PRIMARY KEY (id));
Check tables in Database
mysql> show tables;