Search code examples
phpmysqlsqlphpmyadminrdbms

How to create a table in MySQL from the sql dump of a table taken from other database instance?


I'm using MySQL via PHPMyAdmin.

I've exported one table from one database instance in MySQL.

Now I want to create the same table with the data into another instance of MySQL database from that downloaded sql dump.

Can I create it? If yes, how? If no, why?


Solution

  • You will have to import the dump into your database this could be done from the terminal using

    mysql -u<username> -p<password> <database> < <dump.sql> 
    

    assuming your dump file contains a CREATE TABLE query and then the associated data from the table or that the table already exist in the database.

    You could also do this from phpmyadmin.

    1. First select your database
    2. Click the import button
    3. Select the file you would like to import by clicking File to import
    4. Finally click Go to start your import