Using mysqldump to export databases
mysqldump
If you want to retrieve information from a database for backup or move its contents to another database, the program mysqldump proves to be quite convenient. It is installed at all login-hosts and can be used to generate sql-data from databases and tables.
To retrieve all information from a database:
mysqldump -u andersl_user -p andersl_database > databasefile.sql
With this command a file will be generated with the name databasefile.sql which contains codes for creation of all tables and their contents in the database called andersl_database.
The difference between logging in normally to your mysql-database and this command is that the information gets sent to a file instead of to your ssh-consoll.
You can of course add options so that you only get one table:
mysqldump -u andersl_user -p andersl_database name_of_table > tablefile.sql
Exporting studorg-databases
You can export databases in a studorg in the same way as described earlier as long as you have permission to access the database in some way. For information about permissions and access to databases, see this page.
Importing sql-filer
To import a file you have used mysqldump on to another database, use this code:
mysql -u andersl_user -p andersl_database < databasefile.sql
Other options
The code for importing sql-files can be expanded with more options as to how the tables are imported. As it is written it generates SQL-code for creating tables with data in given database. For further help using mysqldump, use the command man mysqldump.
| Språk: | Kommentarer: | 0 | Aid: | 526 | Brukervurdering: |
|
|
| Sist oppdatert: | 2007-07-29 | Forfatter: | livermor | Lest: | 213 ganger |