Table of Contents
Creating a MySQL database and user via SSH
When you install services such as the ones mentioned above, you are usually asked for at least these 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.
You need to create a database. To do this, follow these steps:
1. Log into your server via SSH
With Mac or Linux, you can directly enter
in your SSH client's window, replacing the numbers with your server's IP.
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 with your server's admin account (no characters will be displayed when you type the password).
2. Log into your MySQL database
Now, log into your MySQL database as root by typing:
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.
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:
gallerywith the name of the database you just created,
ryanwith the username you chose
GanD1dowith the password you chose for your user
5. Exit your server
You may now exit your server by typing:
Complete the installation of your web application
Congrats! You have now created a database on your server with a username and password, which is more than a lot of people do with their day.
Now, simply return to your installation process and enter the information that you now have. For example, we can now provide the following:
- Database location:
- Database name:
- Database username:
- Database password: