Skip to content
Browse files

Add mysql blogpost for creating new databases and users

  • Loading branch information...
1 parent 30612dc commit 04dde2abdef592e29159181d10d14dedd6deb672 @arian committed
Showing with 40 additions and 0 deletions.
  1. +40 −0 source/_posts/setting-up-a-mysql-database.md
View
40 source/_posts/setting-up-a-mysql-database.md
@@ -0,0 +1,40 @@
+title: Setting up a MySQL database
+date: 2013-02-26 21:00:40
+tags: [mysql, reference]
+---
+
+This post is just for future reference with a few MySQL commands I can't really
+remember yet for creating a new database and mysql user. Probably now I posted
+them here, I will remember them ;). So it might be interesting or less
+interesting for you.
+
+First, login as root with:
+
+```bash
+mysql -u root -p
+```
+
+If you forgot your root password, follow
+[these steps](http://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/):
+
+```bash
+sudo service mysql stop
+sudo mysqld --skip-grant-tables &
+mysql -u root mysql
+mysql> UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root';
+mysql> FLUSH PRIVILEGES; exit;
+```
+
+When logged in, create a new database:
+
+```sql
+CREATE DATABASE databasename;
+```
+
+And create a user for it, if we want a separate user at least:
+
+```sql
+GRANT ALL ON databasename.* TO myuser@localhost IDENTIFIED BY 'mypassword';
+```
+
+And that's usually what you need to know.

0 comments on commit 04dde2a

Please sign in to comment.
Something went wrong with that request. Please try again.