Skip to content

Instantly share code, notes, and snippets.

@miguelfrias
Last active August 29, 2015 13:57
Show Gist options
  • Save miguelfrias/9913546 to your computer and use it in GitHub Desktop.
Save miguelfrias/9913546 to your computer and use it in GitHub Desktop.
Mysql Tips & Tricks
# Create user
CREATE USER user IDENTIFIED BY 'password';
# Create and user (if doesn´t exist) and grant permissions
GRANT ALL ON *.* TO 'user'@'localhost' IDENTIFIED BY 'password';
# Update
UPDATE [table] SET [table_field]=[new_value] WHERE [id]=[id];
# Change user password
SET PASSWORD FOR 'user'@'host' = PASSWORD('newpass');
# Backup just one row
> mysqldump -u root -p'password' --compact --no-create-info --where="{field}={value}" {database} {table}; ## The --compact produces a less verbose output (it doesn't drop or lock the table and skips comments). The --no-create-info stops the dump including SQL to recreate the table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment