Skip to content

Instantly share code, notes, and snippets.

@lajlev
Created September 20, 2012 11:04
Show Gist options
  • Save lajlev/3755246 to your computer and use it in GitHub Desktop.
Save lajlev/3755246 to your computer and use it in GitHub Desktop.
Create user and grant access to mysql database
/* Login from terminal */
mysql -u USERNAME -p DATABASENAME;
/* Simple commands */
create database DATABASENAME;
show databases;
use DATABASENAME;
/* Create a user and grant access to database */
grant all privileges on DATABASENAME.*
to 'USERNAME'@'localhost'
identified by 'PASSWORD';
/* Change user password */
SET PASSWORD FOR 'USERNAME'@'localhost' = PASSWORD('NEWPASSWORD');
/* Show grants */
show grants for 'USERNAME'@'localhost';
/* Links */
http://cse.unl.edu/~sscott/ShowFiles/SQL/CheatSheet/SQLCheatSheet.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment