MySQL Table Data Copy
June4
To copy data and a table structure in the same database, say to backup a table, here’s the code…
First, connect onto MySQL – this assumes of course that your mySQL serve allows connections etc., root logon to the db and so on. Typically to localhost, it does.
mysql -h localhost -u root -p
Pump in the password to the root account.
To see all your databases use…
mysql> show databases;
To use one of those databases, use…
mysql> use the_name_of_the_database;
You should get the ‘database changed’ message.
to see the tables in the database, use…
mysql> show tables;
Now you can back up a table if you like…
mysql> CREATE TABLE new_tbl SELECT * FROM original_tbl;
Simple as.