Thursday, October 16, 2014

Create Mysql database and user for PHP applications

Thursday, October 16, 2014 Posted by Andre Broers
I always struggle with the syntax to create a new mysql database and user for a php installation.

Hereby a quick reminder.


azureuser@myhost:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 157
Server version: 5.5.40-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database prestashop;
Query OK, 1 row affected (0.00 sec)

mysql> create user 'prestashopuser'@'localhost' identified by 'xxxxxxxxx';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on prestashop.* to 'prestashopuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
azureuser@myhost:~$ mysql -u prestashopuser -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 158
Server version: 5.5.40-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| prestashop         |
+--------------------+
2 rows in set (0.00 sec)

mysql>