Last active
June 8, 2020 07:18
-
-
Save JorisNienkemper/800a9a60222fa24b23fdffa13a4c6ccd to your computer and use it in GitHub Desktop.
install start and connect with java to docker-mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create docker container mysql8 | |
docker run --name mysql8 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pAssw0rd -e MYSQL_DATABASE=cursistdb | |
-e MYSQL_USER=cursist -e MYSQL_PASSWORD=pAssw0rd -d mysql:latest | |
docker logs -f mysql8 | |
#Look in the logs for creation of database cursistdb with user cursist and password pAssw0rd | |
#From the log | |
#Creating database cursistdb | |
#Creating user cursist | |
#Giving user cursist access to schema cursistdb | |
# Ctrl-C to end docker logs | |
# start bash shell to use mysql client in the container | |
Johns-MacBook-Pro:~ john$ docker exec -it mysql8 bash | |
root@ed8414a90c50:/# whoami -> root | |
root@ed8414a90c50:/# mysql -u cursist -p | |
Enter password: | |
Welcome to the MySQL monitor.... | |
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |
mysql> show databases ; | |
+--------------------+ | |
| Database | | |
+--------------------+ | |
| cursistdb | | |
| information_schema | | |
+--------------------+ | |
2 rows in set (0.01 sec) | |
mysql> CREATE TABLE cursist(....); | |
mysql> exit | |
Bye | |
root@ed8414a90c50:/# exit | |
exit | |
Johns-MacBook-Pro:~ john$ | |
#Useful command to get runtime information about the container | |
docker ps | |
docker inspect mysql8 | |
#Stop the container | |
docker stop mysql8 | |
#Remove the container | |
docker rm mysql8 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment