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
- Cannot end a section without first starting one
- How to set column as primary key in Laravel model
- Get id of last inserted record in laravel
- Add a subselect based on relationship using withAggregate method
- How to check email is valid or not in Laravel
- Save or update pivot table data with additional column in Laravel
- How to get session in blade Laravel ?
- Print query in laravel
- How to get images from AWS s3 and display in Laravel blade
- On delete set foreign id column value null using migration in laravel 8
- Conditional validation in laravel
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- How to display serial number in Laravel?
- How to display HTML tags In Laravel blade
- How to pass query string with pagination in laravel
- How to check find method executed successfully in laravel
- Get laravel version
- Laravel save object to database
- Update existing pivot table data in laravel
- Get previous date data in laravel
- How to get tomorrow and yesterday date in laravel
- Method chaining in Laravel
- Input file with max size validation in laravel
- Always load the relationship data with eager loading in Laravel
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request