Adding users to MySQL MySQL import and export

Create and grant a user access to a mysql database:

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'

GRANT privs ON db.* TO 'user'@'localhost'

Export and import a mysql database:

The option --databases will add USE and IF EXISTS CREATE statements to your resulting.sql file.

the $(date -I) will expand to and ISO style date.

EXPORT:
mysqldump --databases DATABASE -u USER -p > DATABASE-$(date -I).sql

IMPORT:
mysql -u USER -p < DATABASE-$(date -I).sql


Add Comment

Poster Name / Handle / Email:

Comment

Add the words "had nuke"


Back