====== Creating a MySql database and username ======
A Screencast version of this tutorial is available [[en:hosting:using-linux:tutorials:ubuntu:createdatabase-screencast|here]].
This guide is written for Gandi AI users that have installed a MySQL database. If you have not installed a MySQL database, please do so using the Gandi AI interface before continuing.
Popular database-driven PHP websites (ex. phpBB, Plogger, Gallery2, etc...) need access to a database in order to work.
During the installation process, you are asked at one point for at least four things:
* Database location
* Database name
* Database username
* Database password
You need to configure your database before starting the installation process, so that you can fill in this information. Here is how this is done.
Macintosh and Linux users, you can simply use your console for typing these commands. Windows users, you will need to download, install, and use a third-party application such as [[http://www.chiark.greenend.org.uk/~sgtatham/putty/|PuTTY]] to do this.
You need to create a database. To do this,
==== 1. log into your server via ssh: ====
With Mac or Linux, you can directly enter
ssh admin@000.000.000.000
in your SSH client's window, replacing the numbers by your server's IP ([[en:hosting:manage-server:my-ip-address|where can I find this?]]).
In PuTTY, you'll need to enter your server's IP address in the "Host Name" field, and then click "Open". A shell window will open with a "login as" field to fill in. You should login as **admin**; and then give the password associated to your server's admin account ( no characters will be displayed when you type the password).
Gandi support don't hve access to this password. If you have forgotten it, you'll need to create a new server.
==== 2. log into your mysql database ====
Now, log into your mysql database as root by typing:
mysql -p
Then, it will ask you for your password. This is the password that you entered for your database when you installed your MySQL database on your server. If you have forgotten this password, you can reset it via your Gandi AI interface, by clicking on the 'configure' link on your database line.
==== 3. Create the database ====
It is time to actually create the database you will be using for your website. To do this, first choose a good name (we'll use the name gallery as an example), and type:
create database gallery;
...and press enter. You will then see the following appear:
Query OK, 1 row affected (0.16 sec)
This is good, and confirms that the database has been added.
==== 4. Create a database user and password ====
Now, create a username and a password for your new database. The password should be very secure.
Let's say that the username will be 'ryan' and the password will be 'GanD1do'. You will then type the following:
grant all privileges on gallery.* to 'ryan'@'localhost' identified by "GanD1do";
Where you replace:
* **gallery** with the name of the database you just created,
* **ryan** with the username you chose
* **GanD1do**with the password you chose for your user
Then, type:
flush privileges;
and finally:
exit;
==== 5. Exit your server ====
You may now exit your server by typing:
exit
===== Complete the installation of your web application =====
Congrats! You have now created a database on your server with a username and password!
Simply return to your installation process and enter the information that you now have. For example, we can now provide the following:
* Database location: **localhost**
* Database name: **gallery**
* Database username: **ryan**
* Database password: **GanD1do**
DO NOT USE the above example literally for creating your database! For security reasons, please choose a unique username and a good password. You are responsible for the security of your server.
----