Skip to content

Instantly share code, notes, and snippets.

@freshsnippets
Created May 3, 2012 03:15
Show Gist options
  • Save freshsnippets/2582767 to your computer and use it in GitHub Desktop.
Save freshsnippets/2582767 to your computer and use it in GitHub Desktop.
SQL: New DB and User
#
# Connect to the local database server as user root
# You will be prompted for a password.
#
mysql -h localhost -u root -p
#
# Now we see the 'mysql>' prompt and we can run
# the following to create a new database for Paul.
#
mysql> create database pauldb;
Query OK, 1 row affected (0.00 sec)
#
# Now we create the user paul and give him full
# permissions on the new database
mysql> grant CREATE,INSERT,DELETE,UPDATE,SELECT on pauldb.* to paul@localhost;
Query OK, 0 rows affected (0.00 sec)
#
# Next we set a password for this new user
#
mysql> set password for paul@localhost = password('mysecretpassword');
Query OK, 0 rows affected (0.00 sec)
#
# Cleanup and ext
mysql> flush privileges;
mysql> exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment