Skip to content

Instantly share code, notes, and snippets.

@pantoniotti
Created July 4, 2013 01:56
Show Gist options
  • Save pantoniotti/5924342 to your computer and use it in GitHub Desktop.
Save pantoniotti/5924342 to your computer and use it in GitHub Desktop.
MySql Code snippets
### Create New User
$mysql -u root -p
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
### Create New Database
$mysql -u root -p
mysql> CREATE DATABASE testing;
mysql> GRANT ALL PRIVILEGES ON testing.* TO test_user@localhost IDENTIFIED BY 'test_pass';
### Update or change password
MySQL stores usernames and passwords in the user table inside the MySQL database. You can directly update a password using the following method to update or change passwords:
$ mysql -u root -p
mysql> use mysql;
mysql> update user set password=PASSWORD("newpass") where User='ENTER-USER-NAME-HERE';
mysql> flush privileges;
mysql> quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment