Linux/Mysql: Difference between revisions
< Linux
No edit summary |
|||
Line 18: | Line 18: | ||
</pre> | </pre> | ||
== Dump Database from Docker == | === Dump Database from Docker === | ||
<pre> | <pre> | ||
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | ||
Line 28: | Line 28: | ||
</pre> | </pre> | ||
== Import Database in Docker == | === Import Database in Docker === | ||
<pre> | <pre> | ||
docker exec -i mysql-container mysql -uuser -ppassword name_db < data.sql | docker exec -i mysql-container mysql -uuser -ppassword name_db < data.sql | ||
Line 38: | Line 38: | ||
- ./dump.sql:/docker-entrypoint-initdb.d/dump.sql | - ./dump.sql:/docker-entrypoint-initdb.d/dump.sql | ||
</pre> | </pre> | ||
== User Management == | |||
[[Category:Linux]] | [[Category:Linux]] | ||
[[Category:Linux/Services]] | [[Category:Linux/Services]] |
Revision as of 10:35, 13 March 2019
List Databases
mysql -u root -p show databases; mysql -u root -p -e 'show databases;'
echo "show databases;" | mysql
Dump Database
mysqldump -u root -p databasename > databasename.sql mysqldump -u root -p --quick --add-drop-table --complete-insert --allow-keywords databasename > databasename.sql
Dump Database from Docker
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
Import Database
mysql -u root -p databasename < databasename.sql
Import Database in Docker
docker exec -i mysql-container mysql -uuser -ppassword name_db < data.sql
docker-compose:
volumes: - ./dump.sql:/docker-entrypoint-initdb.d/dump.sql