Is there a way to copy all the data in a mysql database to another? (phpmyadmin)

前端 未结 4 403
你的背包
你的背包 2021-01-18 07:27

I want to copy all the tables, fields, and data from my local server mysql to my hosting sites mysql. Is there a way to copy all the data? (It\'s only 26kb, very small)

相关标签:
4条回答
  • 2021-01-18 07:55

    If you have the same version of mysql on both systems (or versions with compatible db file sytsem), you may just copy the data files directly. Usually files are kept in /var/lib/mysql/ on unix systems.

    0 讨论(0)
  • 2021-01-18 08:02

    Please follow the following steps:

    1. Create the target database using MySQLAdmin or your preferred method. In this example, db2 is the target database, where the source database db1 will be copied.

    2. Execute the following statement on a command line:

    mysqldump -h [server] -u [user] -p[password] db1 | mysql -h [server] -u [user] -p[password] db2

    Note: There is NO space between -p and [password]

    I copied this from Copy/duplicate database without using mysqldump. It works fine. Please ensure that you are not inside mysql while running this command.

    0 讨论(0)
  • 2021-01-18 08:03

    Have a look at

    Copying MySQL Databases to Another Machine

    Copy MySQL database from one server to another remote server

    0 讨论(0)
  • 2021-01-18 08:18

    In phpMyAdmin, just export a dump (using the export) tab and re-import it on the other server using the sql tab.

    Make sure you compare the results, I have had phpMyAdmin screw up the import more than once.

    If you have shell access to both servers, a combination of

    mysqldump -u username -p databasename > dump.sql
    

    and a

    mysql -u username -p databasename < dump.sql
    

    on the target server is the much more fast and reliable alternative in my experience.

    0 讨论(0)
提交回复
热议问题