HOW TO INSTALL MYSQL IN UBUNTU 14.04 LTS

MySQL is an open-source database management system, commonly installed as part of the popular LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query Language) to manage its data.

You need to first update your package index, install the mysql-serverpackage, and then run the included security and database initialization scripts.

sudo apt-get update

sudo apt-get install mysql-server 

 OR

To install MySQL 5.6, install the mysql-server-5.6 package,

sudo apt-get install mysql-server-5.6

1

Hit y and continue..

2

Enter a password for the root user and Click OK

Re-enter the password and click OK

3

Note: Mysql “root” account should have a password. Else anyone with an account on your machine will get full access to the database.

sudo mysql_secure_installation

4

5

sudo mysql_install_db

6

In MySQL 5.6, you might get an error like FATAL ERROR: Could not find my-default.cnf. In this case 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

Again try this command

sudo mysql_install_db

7

This is due to some changes made in MySQL 5.6 and a minor error in the APT package.

You can check your version of MySQL with the following command.

mysql –version    (OR)   mysql -u root

If you get an error message saying Access denied for user..

8

That is the normal behavior. You have set a root password for your database so from now on you can’t access it without password. Try the following command.

mysql -u root -p

9

Testing MySQL:

MySQL should start running automatically after installation. To test this, check its status.

service mysql status

If MySQL isn’t running, you can start it with the following command

sudo service mysql start

You can try connecting to the database using the mysqladmin tool, which is a client that lets you run administrative commands. For example, this command says to connect to MySQL as root (-u root), prompt for a password (-p), and return the version.

mysqladmin -p -u root version

10

That’s it!

 

Advertisements

One thought on “HOW TO INSTALL MYSQL IN UBUNTU 14.04 LTS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s