Learning Linux? Today’s lesson shows you how to install MySQL database server on Ubuntu systems.
Students who are learning Linux in college or taking classes for Linux exams will find our tutorials helpful and easy to read. We always focus on new students here.
We start with the basics. We write short, uncomplicated tutorials that students who are just starting will find very encouraging.
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.
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.
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
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
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
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.
About The Author
This post was not written by a robot. I spend my spare time searching for ways to help students and new users get to know and understand Linux, Ubuntu, Windows, and Open Source software.