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:
- 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.
bashdocker exec -it mysql bash
This command will open a Bash shell inside the running MySQL container.
- Login to MySQL: Once you're inside the container, you can log in to MySQL using the
mysql
command-line client.
bashmysql -u root -p
Enter the MySQL root password (dummypassword
in your case) when prompted.
- Create a New Database: After logging in, you can create a new database using the
CREATE DATABASE
SQL command. Replacenew_database_name
with the name you want to give to your new database.
sqlCREATE DATABASE new_database_name;
- Verify Creation: You can verify that the database has been created successfully by listing all databases.
sqlSHOW DATABASES;
You should see your newly created database in the list.
- 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.
sqlexit 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.