Prompt Title: Creating a database in already running docker mysql contianer

Created 8 months ago
Votes 0
Views 236 times
0

Prompt Detail:

To create a new database in the MySQL Docker container that you've already started with the given command, you can follow these steps:

  1. Access the MySQL Container: You need to access the MySQL container to interact with the MySQL server and create a new database. You can do this using the docker exec command.
bash
docker exec -it mysql bash

This command will open a Bash shell inside the running MySQL container.

  1. Login to MySQL: Once you're inside the container, you can log in to MySQL using the mysql command-line client.
bash
mysql -u root -p

Enter the MySQL root password (dummypassword in your case) when prompted.

  1. Create a New Database: After logging in, you can create a new database using the CREATE DATABASE SQL command. Replace new_database_name with the name you want to give to your new database.
sql
CREATE DATABASE new_database_name;
  1. Verify Creation: You can verify that the database has been created successfully by listing all databases.
sql
SHOW DATABASES;

You should see your newly created database in the list.

  1. Exit MySQL and Container: After you have created the new database, you can exit from the MySQL prompt and then exit from the container's shell.
sql
exit exit

Now you've successfully created a new database named new_database_name within your MySQL Docker container. You can use this database for your applications as needed.

avatar
Tinesh Sakthi R
Shared 1 prompt
Created 8 months ago

Leave a Comment

Related Tag Prompts

0
0
docker
1 year ago 2023-03-09 14:58:19 PR
0
0
java
1 year ago 2023-03-22 11:34:09 @dwagh
0
0
안드로이드 도커 사용법
1 year ago 2023-04-17 01:32:05 엄승진
0
0
도커 안드로이드 사용법
1 year ago 2023-04-17 01:33:43 엄승진
0
0
Using Docker 101.
1 year ago 2023-04-29 09:50:40 b
0
0
event-driven application
1 year ago 2023-05-05 11:35:53 Agney
0
0
Generator vežbi sa prazninama.
1 year ago 2023-07-14 12:14:51 ChatGPT