This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux:general:mysql [2019/06/06 14:16] – lunetikk | linux:general:mysql [2020/01/13 22:31] (current) – lunetikk | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | FIXME | ||
- | |||
===== MySQL ===== | ===== MySQL ===== | ||
==== Install ==== | ==== Install ==== | ||
+ | |||
+ | < | ||
+ | apt-get install mysql-server | ||
+ | </ | ||
==== Configure ==== | ==== Configure ==== | ||
- | ==== Backup and Restore ==== | + | Execute the following after the installation |
+ | < | ||
- | To rebuild a table by dumping and reloading it, use mysqldump to create a dump file and mysql to reload | + | You can find the config in |
+ | < | ||
+ | / | ||
+ | </ | ||
- | mysqldump db_name t1 > dump.sql | + | ==== Passwordless login ==== |
- | mysql db_name < dump.sql | + | |
- | To rebuild all the tables in a single database, specify the database name without | + | If you want to automate things you might want to login without |
- | mysqldump db_name > dump.sql | + | === Add profile === |
- | mysql db_name < dump.sql | + | |
- | To rebuild all tables in all databases, use the --all-databases option: | + | :!: WARNING: YOU SHOULD NOT ADD ROOT AS A PROFILE, THE PASSWORD STORE IS NOT SECURE :!: |
+ | Add a profile to your MySQL config | ||
+ | < | ||
+ | |||
+ | You can now login via | ||
+ | < | ||
+ | |||
+ | === Show profiles === | ||
+ | |||
+ | All profiles can be listed via | ||
+ | < | ||
+ | |||
+ | You cant edit the file " | ||
+ | < | ||
+ | |||
+ | ==== Backup and Restore ==== | ||
+ | |||
+ | === Backup === | ||
+ | |||
+ | Backup a single table in a database | ||
+ | < | ||
+ | mysqldump <db> < | ||
+ | </ | ||
+ | |||
+ | Backup all tables in a single database | ||
+ | < | ||
+ | mysqldump <db> > dump.sql | ||
+ | </ | ||
+ | |||
+ | Backup all tables in all databases | ||
+ | < | ||
mysqldump --all-databases > dump.sql | mysqldump --all-databases > dump.sql | ||
+ | </ | ||
+ | |||
+ | Also check out a script to backup all databases from my collegue Tom [[https:// | ||
+ | |||
+ | === Restore === | ||
+ | < | ||
mysql < dump.sql | mysql < dump.sql | ||
+ | </ | ||
+ | |||
+ | Also check out a script to restore databases from my collegue Tom [[https:// | ||
==== Commands ==== | ==== Commands ==== | ||
Line 28: | Line 71: | ||
^ Command | ^ Command | ||
| %%mysqldump%% | | %%mysqldump%% | ||
- | | %%mysqlcheck --repair --databases | + | | %%mysqlcheck --repair --databases |
| %%mysqlcheck --repair --all-databases%% | | %%mysqlcheck --repair --all-databases%% | ||
+ | | %%mysql -uroot -p -h 127.0.0.1 -P 3306%% | ||
==== Troubleshooting ==== | ==== Troubleshooting ==== |