Command to create MySQL Docker image and access the MySQL command-line interface (CLI) within a running Docker container
In this article you will learn about to how to create a docker container named mysql-server using image mysql:latest and will learn about how to access the MySQL command-line interface (CLI) within a running Docker container named mysql-server.
First run the Docker container based on the latest version of the MySQL Docker image.
docker run --name mysql-server -p 3308:3308 -e MYSQL_ROOT_PASSWORD=password -d mysql:latest
Now run command docker exec -it mysql-server mysql -u root -p
allows you to access the MySQL command-line interface (CLI) within a running Docker container named "mysql-server".
docker exec -it mysql-server mysql -u root -p
Here is the detailed information about above command.
docker exec: This is the Docker command to execute a command in a running container.
-it: Specifies that the command should be executed interactively, allowing you to interact with the container's terminal.
mysql-server: Specifies the name of the Docker container to execute the command in.
mysql: This is the MySQL CLI command that you want to execute within the container.
-u root: Specifies the MySQL user to connect as. In this case, it's the root user.
-p: Prompts for the MySQL password.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Return redirect laravel not working
- How to disable timestamps in laravel
- Extract only time from datetime in laravel
- Print query in laravel
- Database transactions in laravel
- How to create static page in Laravel
- Laravel insert query not working
- How to Run CRON Job on LIVE SERVER on Cpanel in Laravel Project
- How to check relationship is loaded or not in Laravel
- How to get query string value in laravel
- Include External CSS and JS file in Laravel
- Define variable and use in Laravel controller method
- Remove array keys and values if it does not exist in other array in Laravel
- Insert dummy data in users table Laravel
- Php artisan make model, factory, migration and controller in single command
- The Pusher library requires the PHP cURL module. Please ensure it is installed
- How to create event and listener in laravel ?
- Property [user] does not exist on this collection instance
- How to get IP address in laravel
- Laravel order by date not working
- The openssl extension is required for SSL/TLS protection but is not available
- How to get session in blade Laravel ?
- Display success message in laravel
- How to send ID to another page in Laravel
- Seed database using SQL file in Laravel