Check this Out!Visit our social network pages for recent updates!

How do You Install MySQL on Ubuntu

MySQL server is the most popular open source database server.. how do you install it on Ubuntu servers?

This brief tutorial shows students how to install and manage MySQL database server on Ubuntu systems.

For those who don’t know, MySQL is a database server. Database servers are programs that provide database services to other programs or computers. They store data for applications and services.

Many of the content management systems like WordPress and Joomla use database servers to store content. So if you’re going to be using these applications to run your websites, learning how to install MySQL database server may come in handy someday.

How To Install WordPress On Ubuntu Servers

Step 1: Preparing Ubuntu Server

Before installing programs and packagesĀ on Ubuntu systems, the first thing you’ll always want to do is update the servers. To do that, run the commands below.

sudo apt-get update

Step 2: Install MySQL Database Server

After updating your systems, run the commands below to install MySQL database server. The commands install the server as well as MySQL database client.

sudo apt-get -y install mysql-server mysql-client

When you run the command above, it will install MySQL packages and prompt you to setup a password for the root user to manage the database server. Type and confirm a new password for the root user on the screen that looks like the one below.

Ubuntu MySQL password prompt screen

After installing MySQL server, these commands below allow you to stop, start and enable the server to automatically start up when you reboot your systems.

sudo systemctl stop mysql
sudo systemctl start mysql
sudo systemctl enable mysql

Also, don’t forget to run the commands to secure the server.. this allows you to enable strong password policy, change the root password to something strong, remove anonymous users, disallow the root from logging in remotely and more.

Run the command below to secure MySQL

sudo mysql_secure_installation

You’ll be prompted with the questions below. Answer them as shown below.

Securing the MySQL server deployment.

Enter password for user root:

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

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: 1
Using existing password for root.

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

... skipping.
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

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
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

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
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...

- 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

All done!

To logon to the server, run the commands below.

mysql -u root -p

You’ll be prompted for the root password you created earlier. Type it to continue.


Leave a Reply