Skip to content

Instantly share code, notes, and snippets.

@samyranavela
Created July 25, 2019 13:40
Show Gist options
  • Save samyranavela/4cdd9c1c2278973b2587d8f132ce7220 to your computer and use it in GitHub Desktop.
Save samyranavela/4cdd9c1c2278973b2587d8f132ce7220 to your computer and use it in GitHub Desktop.
Rename a Database in MySQL
mysql -u dbUsername -p"dbPassword" oldDatabase -sNe 'show tables' | while read table; do mysql -u dbUsername -p"dbPassword" -sNe "RENAME TABLE oldDatabase.$table TO newDatabase.$table"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment