Monday, January 24, 2011

MySQL command help

Command to create mysql user
============================

CREATE USER 'username'@'localhost' IDENTIFIED by 'password';

Command to grant all privileges to a user to databases starting with any name
=============================================================================
GRANT ALL PRIVILEGES ON database_.* TO 'username'@'localhost' IDENTIFIED BY 'password';

flush privileges;

The above two line command will make the user "username" to have all the privileges to add delete modify databases that starts with the name database_.

Command to dump mysql database
==============================
mysqldump -u [databaseusername] -p[password] databasename > databasebackup.sql


Command to restore mysql database
=================================
mysqldump -u [databaseusername] -p[password] databasebackup.sql < databasename

No comments:

Post a Comment

(function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })()