How to Install MySQL on Ubuntu 14.04 LTS

Step 1: Install MySQL


First, you’ll follow a simple best practice: ensuring the list of available packages is up to date before installing anything new.

apt-get update


Installing MySQL is as simple as running just one command:

apt-get install mysql-server php5-mysql


You may receive the following prompt or something similar:

After this operation, 98.2 MB of additional disk space will be used.
Do you want to continue? [Y/n]


Enter Y to continue.


Next you’ll be asked:


New password for the MySQL “root” user:

 

How To Install MySQL on Ubuntu 14.04 LTS

 


This is an administrative account in MySQL with elevated privileges; enter a strong password.


Then you’ll be asked to verify the root MySQL password:


Repeat password for the MySQL “root” user:

 

How To Install MySQL on Ubuntu 14.04 LTS

 


That’s it! Your basic MySQL installation is now complete!


Step 2: Configure and Secure MySQL for Use


Now we’ll instruct MySQL to create its database directory structure:

mysql_install_db


And now let’s secure MySQL by removing the test databases and anonymous user created by default:

mysql_secure_installation


You’ll be prompted to enter your current password. Enter the root MySQL password set during installation:


Enter current password for root (enter for none):


Then, assuming you set a strong root password, go ahead and enter n at the following prompt:


Change the root password? [Y/n] n


Remove anonymous users, Y:


Remove anonymous users? [Y/n] Y


Disallow root logins remotely, Y:


Disallow root login remotely? [Y/n] Y


Remove test database and access to it, Y:


Remove test database and access to it? [Y/n] Y


And reload privilege tables, Y:


Reload privilege tables now? [Y/n] Y


Step 3: Verify MySQL Installation


You can check the version of the MySQL installation with the following command:

mysql -V


Enter the MySQL command client:

mysql -p


You’ll be asked for the root password for the MySQL server, which was set earlier in this tutorial:


Enter password:


And then you should be greeted with the following:


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.5.40-0ubuntu0.14.04.1 (Ubuntu)


Copyright (c) 2000, 2014, 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
owners.


Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.


mysql>


Exit the command line with the following command:

exit


To stop MySQL:

service mysql stop


To start MySQL:

service mysql start


To check the status of MySQL:

service mysql status


To restart MySQL:

service mysql restart

  • 16 Users Found This Useful
Was this answer helpful?

Related Articles

How to List Compiled PHP Modules from Command Line

Pre-Flight Check These instructions are intended specifically for listing compiled PHP modules...

How to Install or Uninstall PECL Extensions

Pre-Flight Check These instructions are intended specifically for installing or uninstalling...

How to Install the MongoDB PHP Driver (Extension) on CentOS 6

Step 1: Setup Environment, Install PHP Extension & Application Repository (PEAR) As a matter...

How to Add a User and Grant Root Privileges on CentOS 6.5

Step 1: Add the User It’s just one simple command to add a user. In this case, we’re...

How to Add a User and Grant Root Privileges on Ubuntu 14.04

Step 1: Add the User It’s just one simple command to add a user. In this case, we’re...

Powered by WHMCompleteSolution