Export MySQL DB Schema

--Export Schema
mysqldump -u user -h localhost --no-data -p database > database.sql



Parameter '@variable' must be defined

Add to Connection String:  "Allow User Variables=True"
.

Export/Restore User passwords during migration

mySql 5.7

Migrate users from DB to DB
mysql -u root -p'password' --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql -u root -p'password' --skip-column-names -A | sed 's/$/;/g' > user_grants.sql
-- MySQL 5.6
mysql  -u root -p'password' --skip-column-names -A mysql -e "SELECT Concat('create user \'', user, '\'@\'', host, '\' IDENTIFIED WITH \'mysql_native_password\' AS \'', password,'\';') FROM   mysql.user where user not in ('mysql.session','mysql.sys','debian-sys-maint','root');" > create_user.sql

-- MySQL 5.7
mysql  -u root -p'password' --skip-column-names -A mysql -e "SELECT Concat('create user \'', user, '\'@\'', host, '\' IDENTIFIED WITH \'mysql_native_password\' AS \'', authentication_string,'\';') FROM   mysql.user where user not in ('mysql.session','mysql.sys','debian-sys-maint','root');" > create_user.sql
mysql -u target_db_ip -u root -p myqsl < create_user.sql
mysql -u target_db_ip -u root -p myqsl < user_grants.sql

https://thedataguy.in/how-to-restore-mysql-users-passwords-during-migration/