Ubuntu/Debian - Installing MySQL


This tutorial walks you through installing MySQL on Ubuntu with the Aptitude repository system.

For this article, we are making these assumptions:

  • You are running a brand-new server with no other software installed.
  • You are running as a normal user with sudo priveledges.

Contents

//

Updating Your Repository

Use this command to ensure that we are  working with a current set of repository data:

# sudo aptitude update

Fixing the Perl Locale

In order to make sure our packages install correctly, we must set the locale information for Perl using the following command:

# sudo aptitude install language-pack-en-base

Updating Your Server

In order to keep our server secure, we need to update all of the software on your server. We will use Aptitude to perform the update using this command.

# sudo aptitude upgrade

Installing MySQL

After the updates are finished, we can install the MySQL server.

1.   Use this command to install:

# sudo aptitude install mysql-server

2.   When you are prompted for your root password, enter it and press OK.

3.   When you are prompted for your root password, enter it and press OK.

After the installation is finished, it begins to run on your server.

Securing MySQL

Now that we have the MySQL server running, we need to secure the installation.

1.   Type this command to start the secure setup script:

# sudo /usr/bin/mysql_secure_installation

2.   When you are asked for your current root password, enter the password you chose earlier and press Enter.

3.   Because you have already chosen a root password, press N and then Enter.

4.   You will be prompted to remove the MySQL anonymous users. For security reasons we want to do this. The text above the question explains this in more detail. Press Y and then Enter.

5.   When you are asked if you would like to disallow remote login for the root user and only allow connections from the server itself, press Y and then Enter to keep the server secure.

6.   MySQL ships with a default database called test. You do not need this and can delete it. Press Y and then Enter to delete the test database and it's associated users.

7.   This step reloads the user settings (called privilege tables) so that all user changes take effect. Press Y and then Enter to continue.

Your MySQL installation is now finished. Keep in mind that this only supports local connections and does not allow you to connect remotely. MySQL - Connect to your database remotely  explains how to make this happen.



Was this content helpful?




© 2014 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER