Skip to content

Instantly share code, notes, and snippets.

@mrtonyhuynh
Last active August 29, 2015 14:02
Show Gist options
  • Save mrtonyhuynh/8153fedd61f233a0fea3 to your computer and use it in GitHub Desktop.
Save mrtonyhuynh/8153fedd61f233a0fea3 to your computer and use it in GitHub Desktop.
Linux Server

Login MySQL

mysql -u root -p

Create User

CREATE USER 'username'@'%' IDENTIFIED BY 'password'

Cấp quyền

GRANT ALL PRIVILEGES ON main.* TO username@'%';

or

GRANT ALL PRIVILEGES ON main.* TO username@'%' IDENTIFIED BY 'password';

Backup

mysqldump db_name > backup-db_name.sql
mysqldump -u userNameHere db_name > backup-db_name.sql
mysqldump -u userNameHere -p db_name > backup-db_name.sql

Restore

mysql -u {DB-USER-NAME} -p {DB-NAME} < {db.file-name.sql}
mysql -u {DB-USER-NAME} -h {MySQL-SERVER-HOST-NAME} -p {DB-NAME} < {backup.db.file-name.sql}
mysql -e "source /path/to/backup-db.sql" db_name_here
mysql -u DB_USER_NAME -p -e "source /path/to/backup-db.sql" db_name_here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment