This guide will outline the method to transfer a database from one User account to another on your dedicated server. Note, the database will be renamed during the process, changing the name to lead with the new User’s username, so any scripts that use it would need to be updated.
For most cases, you’d want to include the db users with the DB, so rename_database_with_user.sh
is the default here.
Old Username: olduser New Username: newuser Database Name: olduser_dbname
Before any action, be sure to create a fully backup of your databases. If you don’t access to DirectAdmin, you can create .sql backups with CustomBuild.
To move olduser_dbname to newuser_dbname including appropriate database user to new, run the following:
cd /usr/local/directadmin/scripts
./rename_database_with_user.sh olduser_dbname newuser_dbname
cd /usr/local/directadmin/scripts
./rename_database.sh olduser_dbname newuser_dbname
If you want to move the databases from one user to another user, you can do so with the following command:
VERBOSE=1 DBUSER="da_admin" DBPASS="da_adminpass" USERNAME="username" NEWUSERNAME="newusername" /usr/local/bin/php /usr/local/directadmin/scripts/change_database_username.php
Where you can grab the da_adminpass from /usr/local/directadmin/conf/mysql.conf
, and of course, replace “da_adminpass”, “username”, and “newuseraname” in the command above with the appropriate information as desired. Read more