Skip to content

Instantly share code, notes, and snippets.

@Xeus
Created August 13, 2013 16:05
Show Gist options
  • Save Xeus/6222726 to your computer and use it in GitHub Desktop.
Save Xeus/6222726 to your computer and use it in GitHub Desktop.
mysql basics
$ mysql -u root
If a password is required, use the extra switch -p:
$ mysql -u root -p
Enter password:
Now that you are logged in, we create a database:
mysql> create database test;
Query OK, 1 row affected (0.00 sec)
We allow user testuser to connect to the server from localhost using the password testpassword:
mysql> grant usage on *.* to testuser@localhost identified by ‘testpassword’;
Query OK, 0 rows affected (0.00 sec)
And finally we grant all privileges on the test database to this user:
mysql> grant all privileges on testdb.* to testuser@localhost ;
Query OK, 0 rows affected (0.00 sec)
And that’s it. You can now check that you can connect to the MySQL server using this command:
$ mysql -u testuser -p’testpassword’ testdb
Your MySQL connection id is 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment