How to transfer MySQL database from Windows to Ubuntu?

6,265

mysqldump is the general method to copy a database over.

Create a dump on windows:

mysqldump -u [USER] -p [DATABASE] > [BACKUP]

Copy the file over to Ubuntu and restore it in Ubuntu:

mysql -u [USER] -p [DATABASE] <./[BACKUP]
  • both commands are done from the shell (not from within MySQL).
Share:
6,265

Related videos on Youtube

MahmoudSenSei
Author by

MahmoudSenSei

Updated on September 18, 2022

Comments

  • MahmoudSenSei
    MahmoudSenSei over 1 year

    I want to transfer my database from WAMP on my local machine to my Ubuntu VPS.

    Can I just copy the folder of the database from C:\wamp\bin\mysql\mysql5.6.12\data to /var/lib/mysql?

    • Rinzwind
      Rinzwind about 10 years
      Ehm I would dump the databases and load them.
  • MahmoudSenSei
    MahmoudSenSei about 10 years
    thx but i have this error "mysqldump is not recognized as an internal or external command"
  • NGRhodes
    NGRhodes about 10 years
    You need to change directory to where you run mysql from.
  • Rinzwind
    Rinzwind about 10 years
    @MahmoudSenSei sorry I am not a windows user. you are on your own ;)
  • MahmoudSenSei
    MahmoudSenSei about 10 years
    Thx i just found the solution, i searched for mysqldump in Wamp and copied it in c:\windows\system32
  • MahmoudSenSei
    MahmoudSenSei about 10 years
    @Rinzwind last thing , should i create an ampty database in the server to dump in it my new database ?
  • Rinzwind
    Rinzwind about 10 years
    Yes. A dump does not make the db itself (you also need permissions to it ;) )
  • MahmoudSenSei
    MahmoudSenSei about 10 years
    @Rinzwind permissions ?
  • MahmoudSenSei
    MahmoudSenSei about 10 years
    u mean the user should have all privileges ?
  • Rinzwind
    Rinzwind about 10 years
    permissions as in GRANT PRIVILEGES etc.
  • Sanal S
    Sanal S over 5 years
    what if mysql crashed and won't start on windows. how can i transfer database from windows to ubuntu in such case?