Installing MySQL Web Server (DigitalOcean droplet)
Greeting Steemit Family
Here after installing Apache, we go ahead to install Mysql on our server. I keep learning, and when I get a chance share what I am doing so far. Our target is to have a full fresh web host server, which we can host a dynamic web app and also use the mail service.
At this point, we have our droplet, which logs via Bitvise SSH client or putty. We have created an unprivileged user and assigned sudo privileges. We are gradually putting the LAMP stack running on the droplet. LAMP (Linux, Apache, MySQL, PHP/Python/Perl), which we had Linux running when creating the droplet, and the previous post on Digital Ocean. We were installing Apache. At this point, we are done with Linux, and Apache, and time to install MySQL now.
Same as I share the link to guide us in installing Apache. I will use Digital Ocean documentation to install Mysql. Note we have to login into our droplet, and we are working from the unprivileged user.
I have logged in, let's check to see if our Apeach is running without any bugs.
sudo apt update
We can remember the reason for the apt update, which will help update the package list. This will help us to be working on the latest version of packages on the system.
sudo apt install mysql-server -y
Now, time to install the Mysql package, and the -y
and end of the command are to help auto-accept and prompt. Without that, you need to respond at some stage by typing y which will stand for yes.
systemctl start mysql.service
For some reason, the MySQL service was not running. After some level of research, I had to resize my droplet adding more RAM and CPU.
We are good to go now. I checked the status again, and it is active.
systemctl status mysql.service
At this point, our package is installed. For us to be able to use any mysql command. We need to open the Mysql command line. Now we can access MySQL without a password, but it is recommended to assign a password for security.
sudo mysql
This will open the Mysql command line, and next to change the authentication method. The default user is the root, here we have to change the authentication to an old and simple method mysql_native_password
mysql-> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<your_pass_here>';
The last section of the command, <your_pass_here>. Replace with your desired password. After altering the settings, it is recommended to reload the tables.
mysql-> FLUSH PRIVILEGES;
At this point, we can create a database and a table in MySQL. Now, we have to log in to MySQL as root, which we assign a password above. For security reasons, please have strong passwords and guard them with your life. I'm logged in, let's start.
CREATE DATABASE new_database;
For you to be able to create a table, I have to select the database. In my case the database is new_database
USE my_database;
Now we can go ahead to create our table and column, and check if the table was created. you have the command on the screenshot bellow.
Type exit, to close the mysql command and back to the droplet.
Stay on, we are gradually moving to a LAMP stack server, which we can host a dynamic web project.
Cheers
Thanks for dropping by
@fombae
Upvoted! Thank you for supporting witness @jswit.
Another wonderful tutorial by your side! You've made installing MySQL on a droplet that's look so easy.
I really appreciate the step-by-step guide and screenshots. Your explanation of each command is very clear and concise.
Keep sharing your knowledge, and I'll be looking forward to your next post on completing the LAMP stack! Wish you all the best for your participation.