title: How to export all databases, users and privileges of MariaDB
body: <p>I have a server with 800 databases, over 600 users with lots of different privileges. I know I can use <code>mysqldump</code> to export all the databases but I still didnt find a safe/easy way to export all users and their privileges.</p>
  <p>Googling, I found lots of different commands to list all users and query each user's privileges, append that to a file and keep going till last user. Is this really the safest method to export such important information? I really need to make sure the exported users/privileges are exactly as the ones in the server, I cant afford a shell command (loop) that may fail when exporting some user, or some user privilege...</p>
  <p>And one final question: I know <code>mysqldump --all-databases</code> will not export <code>information_schema</code> and <code>performance_schema</code> (which is great) but it still exports the <code>mysql</code> database! Why? I think it's not safe to export this <code>mysql</code> database since I will probably be importing it later on a MariaDB with a more recent version! Right?</p>