Ubuntu 14.04 defaults to MySQL 5.5, but also has MySQL 5.6 available for installation from the universe archive.
Step 1: Install MySQL Server 5.6
Install mysql-server 5.6 with apt-get command :
sudo apt-get update sudo apt-get install mysql-server-5.6
To install MySQL 5.6, install the mysql-server-5.6 package instead.
sudo apt-get install mysql-server-5.6
There are two ways to install MySQL. You can either use one of the versions included in the APT package repository by default (which are 5.5 and 5.6), or you can install the latest version (currently 5.7) by manually adding MySQL’s repository first.
If you want to install a specific version of MySQL, follow the appropriate section below. To help you decide which version is best for you, you can read MySQL’s introduction to MySQL 5.5, then what’s new in MySQL 5.6 and what’s new in MySQL 5.7.
If you’re not sure, you can just use the mysql-server APT package, which just installs the latest version for your Linux distribution. At the time of writing, that’s 5.5, but you can always update to another version later.
To install MySQL this way, update the package index on your server and install the package with apt-get
Installing MySQL 5.7
If you want to install MySQL 5.7, you’ll need to add the newer APT package repository from the MySQL APT repository page.Download the .deb package to your server.
wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb
You’ll see a prompt that asks you which MySQL product you want to configure. The MySQL Server option, which is highlighted, should say mysql-5.7. If it doesn’t, press ENTER, then scroll down to mysql-5.7 using the arrow keys, and press ENTER again.
Once the option says mysql-5.7, scroll down on the main menu to Apply and press ENTER again. Now, update your package index.
sudo apt-get update
sudo apt-get install mysql-server
Step 2: Configuring Mysql
First, you’ll want to run the included security script. This changes some of the less secure default options for things like remote root logins and sample users.
$ sudo mysql_secure_installation
You can check your version of MySQL with the following command.
$ mysql --version
You’ll see some output like this:
mysql Ver 14.14 Distrib 5.7.11, for Linux (x86_64) using EditLine wrapper
If you’re using a version of MySQL earlier than 5.7.6, you should initialize the data directory by running mysql_install_db.
Note: In MySQL 5.6, you might get an error that says FATAL ERROR: Could not find my-default.cnf. If you do, copy the /usr/share/my.cnf configuration file into the location that mysql_install_db expects, then rerun it.
sudo cp /etc/mysql/my.cnf /usr/share/mysql/my-default.cnf sudo mysql_install_db
The mysql_install_db command is deprecated as of MySQL 5.7.6. If you’re using version 5.7.6 or later, you should use mysqld –initialize instead.
Step 3: Testing Mysql
Regardless of how you installed it, MySQL should have started running automatically. To test this, check its status.
$ service mysql status
You’ll see the following output (with a different PID).
mysql start/running, process 2689
If MySQL isn’t running, you can start it with
$ sudo service myql start
$ mysqladmin -p -u root version
mysqladmin Ver 8.42 Distrib 5.5.47, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2015, 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
Server version 5.5.47-0ubuntu0.14.04.1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 4 min 15 sec
Threads: 1 Questions: 602 Slow queries: 0 Opens: 189 Flush tables: 1 Open tables: 41 Queries per second avg: 2.360