Ubuntu install MySQL

1 minute read

Prerequisites

To follow this tutorial,you will need: One ubuntu 14.04 Droplet with a sudo non-root user.

# Step1-Installing MySQL If you want to install MySQL 5.5 or 5.6 specifically,the process is still very straightforward.First,update the package index on you server.

    sudo apt-get update

Then,to install MySQL 5.5 ,install the mysql-server-5.5 package.

    sudo apt-get install mysql-server-5.5

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

    sudo apt-get install mysql-server-5.6

For both options,you’ll be prompted to create root password during the installation.Chosse a secure one and make sure you remmemeber it,because you’ll need it later.

Step2- Configuring MySQL

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

    mysql --version

Step3- Connection MySQL

   $ mysql -u root -p

Then ,to enter your password.

Install MYSQL UI

    sudo apt-get install mysql-workbench

Trouble

  1. Error 1046 No database Selected,how to resolve? You need to tell MySQL which databe to use:
        USE database_name;
    
Before you crate a table .
In case the database does not exist,you need to create it as:
        CREATE DATABASE database_name
    
followed by:
        USE database_name;
    
  1. Show Mysql Port
        mysql>show variables like 'port';
        +---------------+-------+
        | Variable_name | Value |
        +---------------+-------+
        | port          | 3306  |
        +---------------+-------+
        1 row in set (0.00 sec)
         
        mysql>

    

Leave a Comment