--Summary of how to read dump file into MySQL of Docker
--Hardware environment
item | information |
---|---|
OS | macOS Catalina(10.15.5) |
hardware | MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports) |
Processor | 2 GHz quad core Intel Core i5 |
memory | 32 GB 3733 MHz LPDDR4 |
Graphics | Intel Iris Plus Graphics 1536 MB |
--Software environment
item | information | Remarks |
---|---|---|
dump file creation MySQL version | 8.0.19 for osx10.13 on x86_64 | Introduced by this method using Homebrew →Install MySQL with Mac Homebrew |
dump file read MySQL version | 8.0.19 for osx10.13 on x86_64 | Introduced by this method using Homebrew →Install MySQL with Mac Homebrew |
--The dump file is prepared locally on your PC. --The MySQL container is running.
--Read the dump file Docker's MySQL is the environment prepared by your senior. -Laravel course starting with Docker --Laravel edition
Move dump file
Use the $ cd
command to move to the directory where the dump file is located.
Execute the following command to copy the dump file into the docker container.
```terminal
$docker cp dump file name container name:/Copy destination dump file name
```
For example, if you want to copy my_dump.sql directly under the local ~ / Downloads
directly under the root directory of the container name" docker_mysql_1 ", it will be as follows.
```terminal
$ docker cp ~/Downloads/my_dump.sql docker_mysql_1:/my_dump.sql
```
Read
Execute the following command to enter the MySQL container.
```terminal
$ docker exec -it container name bash
```
Execute the following command to read the dump file.
```terminal
$ mysql -u MySQL username-password associated with pMySQL user name DB name to read dump file<dump file name
```
Confirmation
Execute the following command in the MySQL container to log in to MySQL.
```terminal
$ mysql -u root -p
```
Execute the following SQL and check that the contents of the dump file are read normally and the tables etc. exist.
```sql
DB name that read use dump; show tables; ```
Recommended Posts