Export/Backup your MySQL database to a .sql
mysqldump -u [uname] -p db_name > ~/db_backup.sql
Copy the .sql file for other server
Copy the generated file, on your user’s home to the new server with scp.
scp ~/db_backup.sql [email protected]:/home/username
Create a new database to import it into
Login into the mysql
mysql -u root -p
Create the database
create database database_name;
Import/Recover your .sql files to mysql
mysql> use database_name;
mysql> source /full/path/your_file.sql;
Create and grant privileges for your NON ROOT user
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Grant privileges for your NON ROOT user use it.
grant all privileges on database.* to username@localhost identified by 'password'; FLUSH PRIVILEGES;