There is a great tutorial on installing Apache, MySQL, PHP on www.digitalocean.com. Below I propose a fast-forward guide.
-
1. Open a terminal. Right click on your desktop, and click Open in terminal. If on server version of Ubuntu just go to the next step.
-
2. Type the following command and hit ENTER to download package information from all configured sources. You may skip this step if recently done it.
$ sudo apt update
-
3. Type the following command and hit ENTER to install MySQL.
$ sudo apt install -y mysql-server
-
4. Type the following command and hit ENTER to access MySQL server.
$ sudo mysql
-
5. Type the following command and hit ENTER to setup separate root password for MySQL server. You should write down this one. It gives you full access to MySQL server.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mysqlrootpassword';
-
6. Type the following command and hit ENTER to exit MySQL server.
mysql> quit;
-
7. Type the following command and hit ENTER to secure MySQL installation.
$ sudo mysql_secure_installation
- Type the ROOT PASSWORD that you set previously and hit ENTER.
- Hit "y" and ENTER for VALIDATE PASSWORD.
- Choose 0, 1 or 2 for level of password complexity. Lets say "1" and ENTER.
- You got to the password of 'root' in mysql server. Be carefull!!! If your previously set password does not meet password validation policy (for "1" - 8 characters, mixed case, special characters) you might need to change it now. Write down this password as it becomes your new root password for MySQL. Password must meet requirements set above.
Enter your password. This is a different password from that for the 'root' of your system and you should keep them different.
- Remove anonymous user? Hit "y" and ENTER.
- Disallow root login remotely? Hit "y" and ENTER.
- Remove test database and access to it? Hit "y" and ENTER.
- Reload privilege tables now? Hit "y" and ENTER.
-
8. Create a new user for MySQL server. This user will be used by Prvstorage application.
Type the following command and hit ENTER to access mysql server.
$ sudo mysql -p
for [sudo] pasword for 'yourusername' enter the ubuntu password.
for Enter password: enter the root password set for MySQL previously.
-
9. Type the following command and hit ENTER to create new database needed by Prvstorage application.
Replace 'prvstoragedatabase' with a database name of your choice.
Write down database name, you'll need it later.
Don't forget the final ";" of mysql command.
mysql> CREATE DATABASE prvstoragedatabase;
-
10. Type the following command and hit ENTER to create new mysql user with new password.
ATTENTION !!! Password must meet requirements set when you ran mysql_secure_installation..
Replace 'newuser' and 'password' with a username and password of your choice.
Write down username and password, you'll need them later.
Don't forget the final ";" of mysql command.
mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
-
11. Type the following commands and hit ENTER to grant privileges to 'newuser' on 'prvstoragedatabase'.
Don't forget the final ";" of mysql command.
mysql> GRANT ALL PRIVILEGES ON prvstoragedatabase.* TO 'newuser'@'localhost';
Then...
mysql> FLUSH PRIVILEGES;
To leave mysql, type the following command and hit ENTER:
mysql> quit;