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

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s


%d bloggers like this: