To install MySQL Server on Ubuntu, make your way to a Terminal window or a command prompt, and type this command:
sudo apt-get install mysql-server-5.7
(As of this writing, MySQL Server version 5.7 is the latest version available in the Ubuntu repositories, though future versions of Ubuntu may receive the newer versions of MySQL.)
Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just as the root user in Linux has complete control over the system, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.
(Note that in the password dialog box, if you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)
After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line.
Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:
First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).
Next, the script will ask you to setup the VALIDATE PASSWORD plugin, which checks passwords for appropriate strength. Hit Y to accept, and then set the password strength level by hitting 0 for Low, 1, for Medium, and 2 for Strong.
Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.
After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.
After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.
The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.
MySQL server is now installed on your Ubuntu system.
Was this post helpful? These books might be useful: