How I duplicate a database in my linux?

February 12, 2016 554 views
MySQL Nginx Ubuntu

I have ubuntu 14 (nginx) and I'm ran that command to duplicate/export my database:

mysqldump -u[user] -h[localhost] -p[pwd] database1 > /home/database1.sql

And after I ran to import:

mysql -u[user] -h[localhost] -p[pwd] database2 < /home/database1.sql

And I get that message:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql neurocriativi > /home/neurocriativi.sql' at line 1

  • What's the first line contained in /home/database1.sql?

  • Hello! I got it now, my mistake was ran the command into 'mysql >'
    I ran the same command line out, in shell and it worked.

    But when I restarted nginx I got fail....

    Then I ran...

    nginx -t

    And I get...

    nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
    2016/02/12 10:36:50 [warn] 6536#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    2016/02/12 10:36:50 [emerg] 6536#0: open() "/run/" failed (13: Permission denied)
    nginx: configuration file /etc/nginx/nginx.conf test failed

    The solution was ran the restart nginx by root.

1 Answer

Hi Nayara,

When dumping your database1 in database1.sql file, you should see a line saying : USE database1
If you want to restore this dump in database2, then you may just comment the line showing the database to use and relaunch your mysql import command again.
Then it should work ^^

Hope this helps

Have another answer? Share your knowledge.