1

I am migrating to a docker MariaDB setup and all my users were created w/ "Localhost". From what I read and tested ironically '%' excludes localhost. I want to copy my existing users adding a second entry utilizing '%' as the hostname. Any suggestions?

FreeSoftwareServers
  • 248
  • 1
  • 4
  • 14

2 Answers2

2

You have to call SHOW CREATE USER 'username'@'localhost' and SHOW GRANTS FOR 'username'@'localhost' for all the users fetched by

SELECT user, host 
  FROM mysql.user
 WHERE host = 'localhost'

and to replace all 'localhost' entries by '%' in the returned statements.

Kondybas
  • 4,800
  • 19
  • 16
0

You can use mariadb-dump (previously called mysqldump) to dump all the users and their grants to an SQL file:

mariadb-dump --system=users > /tmp/users.sql

If you really want to copy all localhost users to % users, then use the search-and-replace feature in your favourite GUI editor. Or, in a Unix-like environment you can do something like:

 sed -i 's/localhost/%/g' /tmp/users.sql
dbdemon
  • 6,964
  • 4
  • 21
  • 40