As the manual says in Copying Databases you can pipe the dump directly into the mysql client:
mysqldump db_name | mysql new_db_name
If you’re using MyISAM you could copy the files, but I wouldn’t recommend it. It’s a bit dodgy.
Integrated from various good other answers
Both mysqldump
and mysql
commands accept options for setting connection details (and much more), like:
mysqldump -u <user name> --password=<pwd> <original db> | mysql -u <user name> -p <new db>
Also, if the new database is not existing yet, you have to create it beforehand (e.g. with echo "create database new_db_name" | mysql -u <dbuser> -p
).
Related Posts:
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- How do I restore a dump file from mysqldump?
- How do I quickly rename a MySQL database (change schema name)?
- Authentication plugin ‘caching_sha2_password’ cannot be loaded
- Create a new database with MySQL Workbench
- How to get size of mysql database?
- 1052: Column ‘id’ in field list is ambiguous
- 1052: Column ‘id’ in field list is ambiguous
- difference between primary key and unique key
- How to create a foreign key in phpmyadmin
- importing a CSV into phpmyadmin
- How to check if mysql database exists
- Is there a Profiler equivalent for MySql?
- How to do a batch insert in MySQL
- Error: Duplicate entry ‘0’ for key ‘PRIMARY’
- Data is not constantly loading from custom wordpress table
- What’s a good strategy for planning WordPress DB growth?
- How do I load a sql.gz file to my database? (importing)
- “INSERT IGNORE” vs “INSERT … ON DUPLICATE KEY UPDATE”
- Export Pervasive to MySQL (C#)
- MySQL SELECT increment counter
- what does “/index.php?admin/admin_dashboard” in my url mean
- How to join two tables by multiple columns in SQL?
- MySQL Error 1093 – Can’t specify target table for update in FROM clause
- mysqladmin: connect to server at ‘localhost’ failed
- mysql update multiple columns with same now()
- Usage of MySQL’s “IF EXISTS”
- Getting java.sql.SQLException: Operation not allowed after ResultSet closed
- MySQL equivalent of DECODE function in Oracle
- How to copy a row and insert in same table with a autoincrement field in MySQL?
- CAST to DECIMAL in MySQL
- Error Code 1292 – Truncated incorrect DOUBLE value – Mysql
- MySql – HAVING vs WHERE
- How to stop mysqld
- WordPress site migration – icons missing
- WordPress Database lost auto increment
- Slow wp_term_relationships query
- Optimize Multiple Taxonomy Term MySQL Query?
- How to use “TRUNCATE TABLE” MySQL statement?
- WordPress MySQL & PHP Performance
- What specific database privileges does WordPress need?
- Slow SQL_CALC_FOUND_ROWS Query
- How is the data stored in the database?
- Using source control with WordPress
- Updating User Meta with SQL Query
- How do I write this SQL statement for Posts written in last 24 hours?
- wpdb prepare syntax
- How to run this SQL query of wp_terms database
- WooCommerce – Query for ordered products
- How to find if a post with custom_field == X exists?
- How to change post format from Aside to Image for all posts?
- How to add and SQL query of posts only published
- Slow Mysql Queries
- can database and media folder be moved to a different drive?
- Manually removing revision post types
- Select Multiple meta_value from WP DB; Single Query
- Is it possible to split database tables using HyperDB?
- What happens if I overwrite the current wp_options table with a backup from a week ago?
- writing inner join in wpdb
- Unknown collation when I import a dump from an existing site into a development database?
- PHP script can’t connect to Database on port 3307
- How to Mirror WordPress database from Remote server to Local server
- Is MariaDB’s Aria storage engine suitable for WordPress?
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- How do I query wp_options for expired transient pairs with MySQL commands?
- Automatic switch to backup database on fail
- How to translate this mySQL query to $wpdb query
- Separate DB by yearly archive of WordPress
- WordPress running SQL query to update database from form
- How to fix database error duplicate entry
- How do I convert a MySQL database from utf8mb4 to utf8 encoding?
- Update MySQL query so that it functions again
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Why this query is not showing any result on wordpresss home page?
- Query posts by custom taxonomy and sort by post_modified
- WordPress $wpdb get posts from category and sort by custom meta
- Trouble running $wpdb->query() with last_insert_id
- External wpdb connections in different plugins on single page
- Array Formation Issue
- Migration problems with mysql: Operation not allowed when innodb_forced_recovery > 0 [closed]
- wp_usermeta – Read from database, but save function broken
- How to get product order by two custom taxonomy in wordpress
- Having problem creating local instance of wordpress site
- WordPress $wpdb no result
- Integrating Custom Database with WordPress
- Please help! I have a problem with getting wordpress databas
- when using $wpdb sudden connection rejection without changing anything. Access denied, with errors from repair tool
- edit_user_created_user hook – using to update Groups
- Bulk find & replace on WordPress posts/pages (minus image paths)
- WordPress database problem wp_posts, primary key
- Improving performance of SQL sub-queries in WordPress
- Missing latest posts and options after DB migration via phpMyAdmin
- Saving custom term value to the database in new table
- “MySQL server has gone away” since update to 3.8
- MYSQL Join on meta key value?
- Complicated MySQL Query
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- How can I delete the options from DB when the plugin is deleted?
- Batch Replace URLs in WordPress Database