Moving Users on MySQL

Copying users from a database on host1 to a database on host2 under MySQL:
echo "select concat(\"show grants for '\", user,\"'@'\", host, \"';\") from user where host='localhost' or host = '127.0.0.1';" | mysql -u root -p --skip-column-names -h host1 mysql | mysql -u root -p --skip-column-names -h host1 mysql | sed 's/$/;/' | mysql -u root -p -h host2

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: