Installing MySQL Server in Ubuntu 16.04

Posted on

Server Operating System        : Ubuntu 16.04 (Xenial Xerus)

Basically, this is a post which is made to describe on how to uninstall MySQL Server installation in Ubuntu Linux distribution. I decide to uninstall MySQL server because it has already crashed. Due to the space storage which has already full caused the operation performed by MySQL service to write data has already failed. I am trying to recover it but the process itself has come to a dead end.  Instead of wasting lots of time for troubleshooting  trying to straight up MySQL Server in order to be properly functioned, I decide to uninstall it and reinstall it with a brand new one. Below is the installation process :

  1. Using apt-get command, we can remove any kinds of package which have already been installed. The execution of the command is shown below :
apt-get install mysql-server
  1. After finishing on execute the above command, we will execute another command which is shown as follows with the steps explained :

root@hostname:~# /usr/bin/mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

In the above entry part, we have to enter the password which is assigned to ‘root’ user.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: Y

Since this VALIDATE PASSWORD plugin is a new thing added in this version of MySQL, we will try to setup VALIDATE PASSWORD plugin. Type ‘Y’ for yes and start to setup it.  

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.

I type 0 for low level of password validation policy since this is only a workstation I used as a local development.

Estimated strength of the password: 50
Change the password for root ? ((Press y|Y for Yes, any other key for No) : No

I also type No to change the root password since I have already picked the simplest password for root because of local development environment.

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother.You should remove them before moving into a production environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y

Just remove anonymous users by typing Y in the above entry.

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y

Disallow root login by typing ‘Y’ in the above entry.

By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...

Dropping test database by typing ‘Y’ in the above entry.

 - Removing privileges on test database...
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

Reloading all the tables privilege by typing ‘Y’ in the above entry.

All done!
  1. Since the installation process has already finished, we can now begin to start the service by typing the following command :
systemctl start mysqld.service
root@hostname:~# systemctl start mysql.service
  1. Check MySQL service status after starting it by executing the following command :
systemctl status mysql.service
root@hostname:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Jum 2016-06-24 22:48:20 WIB; 4min 28s ago
 Main PID: 27405 (mysqld)
   CGroup: /system.slice/mysql.service
           └─27405 /usr/sbin/mysqld
Jun 24 22:48:16 hostname systemd[1]: Starting MySQL Community Server...
Jun 24 22:48:20 hostname systemd[1]: Started MySQL Community Server.
Jun 24 22:52:43 hostname systemd[1]: Started MySQL Community Server.
  1. Try to login into MySQL console with the password which is being set in the previous installation step :
root@hostname:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.12-0ubuntu1.1 (Ubuntu)
Copyright (c) 2000, 2016, 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
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

When we can log in into MySQL console, it means that the installation process has succeed and MySQL service is running properly.


2 thoughts on “Installing MySQL Server in Ubuntu 16.04

Leave a Reply