Best Practice for SQL Users Backup
While the quick user backup as this one-line commandmysqldump -u [user] -p mysql > [Path]/[user_backup_filename].sql might work when you have same version for backup and restore SQL. In most cases, you want to implement something similar to the following bash script
Step 1: On your server, in terminal, prepare the following bash file using vi (or vim or any text-editor of choice)
Step 2: Paste in the content of the file as follow:
Step 3: make sure you (or the user that run the mariadb_user_backup.sh file has the sufficient permission (i.e. chown) and make the script file executable:
Step 4: Execute the script file to obtain the user backup file
Similar to the guide .
If your new SQL server is newer than your old one, after importing both database(s) and users, you can run the following command in terminal to upgrade MySQL: