Skip to main content

Move or duplicate database

Comments

6 comments

  • kodeslogic
    As a root user, you can use the below command to restore the DB: mysql user2_db < db_backup.sql example: mysql database_name < database-backup-file.sql
    After that give privileges to the new user to access the database user2_db
    0
  • HostNoc
    HI Dont use phpmyadmin if your database size is huge and restore your database using following command. Run following command on screen so if you have any issue with internet etc process will run in back ground. mysql -u [user] -p [database_name] < [filename].sql Regards
    0
  • cPRex Jurassic Moderator
    Good replies, all!
    0
  • Handssler Lopez
    mysql user2_db < db_backup.sql example: mysql database_name < database-backup-file.sql
    Thank you very much as I understand this command what it does is restore the .sql file in the database only that I need to be connected to the internet all the time mysql -u [user] -p [database_name] < [filename].sql
    @HostNoc And with this code I can run it and it will continue in the background as the database to be restored is 20GB, it may take several hours. Can I run it through terminal, close the terminal, and leave it working during off-peak hours on the server? @kodeslogic, @HostNoc, @cPRex According to your answers, it means that it is not possible to just copy or move a database from user account1 to user account2. Is this correct or do you consider it to be very complicated and the best are your previous recommendations? in advance always thank you for your time and attention I edit: it does not matter that the .sql file is in the / home / of the account or I must change it to the home of the server or put some path in when restoring the database since I plan as root through the terminal navigate to the / home / of the account and there execute the commands is this action correct?
    0
  • HostNoc
    HI no its not possible to move or copy data from one user to another user. You will have to restore one user to another user. Regards
    0
  • cPRex Jurassic Moderator
    You would want to run that specific code in a screen session as it will be active in the terminal window. You are correct about not being able to copy database data across users. It's a backup and restore operation as @HostNoc mentioned.
    0

Please sign in to leave a comment.