Editing
Using mysqldump
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Workaround to select tables with a wildcard === Wildcards aren't supported by `mysqldump`. Each table has to be listed. Put the table names in a file with: <syntaxhighlight lang="bash" enclose="div"> $ mysql -u [username] -p [password] -N information_schema -e "SELECT table_name FROM tables WHERE table_schema LIKE '[source_schema]' AND table_name LIKE '[table_pattern_]%'" > tables.txt </syntaxhighlight> Edit the file to put all the table names into a single line. * Edit the file with `vim`. * In `vim`, <kbd>J</kbd> will join the current line with the next line. <kbd>[n]J</kbd> joins the next ''n'' lines together, e.g. <kbd>3J</kbd>. Then the file can be used to specify the table names: <syntaxhighlight lang="bash"> $ mysqldump --user=[username] --password=[password] [source_schema] `cat tables.txt` > dump_file.sql </syntaxhighlight> Optionally, edit `dump_file.sql` to change table names: :Search & replace with `vim`: :<kbd>:s\foo\bar\g</kbd> will change occurrences of "foo" to "bar" on the current line only. :<kbd>:%s\foo\bar\g</kbd> will change all occurrences of "foo" to "bar" :<kbd>:%s\foo\bar\gc</kbd> will change all occurrences of "foo" to "bar" with confirmation for each occurrence. Connect to the schema and import the data from the dump file: <syntaxhighlight lang="bash"> $ mysql --user=[username] --password=[password] [destination_schema] mysql> source dump_file.sql </syntaxhighlight> [http://zetcode.com/databases/mysqltutorial/exportimport/ Exporting and Importing MySQL Data] documents some alternative methods for importing and exporting.
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information