Move or duplicate database
Hello dear, today I have the following question, I want to move or duplicate a database from user1 to user2
the database is very large and it is I need to have this database in another account / another user always from the same server
user1 -> BD move or copy it to user2
if this is not possible.
I have the database in .sql in the / home / directory of the account, what commands should I use to be able to restore the database? over another for example user2_db
** Note ** I have not used the phpmyadmin db import option because this database is several GB.
MariaDB 10.3.29-MariaDB
-
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 databaseuser2_db
0 -
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 -
Good replies, all! 0 -
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 timemysql -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 -
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 -
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.
Comments
6 comments