• on first machine dump mysql.user table:
    mysqldump -u root -p mysql --tables user > users.sql
    • command will ask for password
  • import file “users.sql” on second machine:
    mysql -u root -p mysql < users.sql

WARNING: This does not work between some versions. Certainly not from 5.5 to 5.7. If you restore user table dumped on 5.5 on 5.7 next time you will try to add user or privileges you will see error “ERROR 1805 (HY000): Column count of mysql.user is wrong. Expected 45, found 42. The table is probably corrupted”. And of course vice versa – expected count of columns can be lower then count found.