
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
- Property [user] does not exist on this collection instance
- Validation for multiple forms on same page in laravel
- How to display HTML tags In Laravel blade
- How to pass data to multiple partial view files in laravel
- Retrieve count of nested relationship data in Laravel
- Seed database using SQL file in Laravel
- Touch parent updated_at in Laravel
- How to remove P tag from CkEditor in Laravel?
- Class 'App\Providers\Auth' not found
- Target class [admin] does not exist.
- How to include header file in laravel
- How to check query string exists or not in laravel blade
- Remove several global scope from query
- How to get images from AWS s3 and display in Laravel blade
- Array to string conversion laravel blade
- Laravel 9 pagination with search filter
- How to add foreign key in laravel using migration
- Laravel 10 starter app using breeze on live server
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
- Laravel URL validation not working
- Add class to body in laravel view
- Submit form without CSRF token in Laravel
- SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
- Pass variable from blade to controller Laravel
- How to check duplicate entry in laravel