Mysql installation steps


Basic System Configuration


1. Add fully qualified domain name in
  /etc/hosts file

     127.0.0.1 localhost.localdomain localhost
     12.34.56.78 servername.example.com servername

2. Add host name in /etc/hostname
      echo "servername" > /etc/hostname
      hostname -F /etc/hostname


Installing MySQL


Make sure your package repositories and installed programs are up to date by issuing the following commands:

1. apt-get update
2. apt-get upgrade --show-upgraded
3. apt-get install mysql-server

 

To change privileges of mysql use this command  and change root password

   mysql_secure_installation

Using MySQL

Type following command at your prompt: mysql -u root -p

Forgot password recovery

If you’ve forgotten your root password, use the package reconfiguration tool to change that password:
1. dpkg-reconfigure mysql-server-5.1

Let’s create a database and assign a user to it:-

Create New database

   CREATE DATABASE testdb;

Create New User

   CREATE USER 'username'@localhost IDENTIFIED BY 'password';

Delete existing user

 DROP USER 'username'@'localhost';

Grant permission to user

GRANT ALL PRIVILEGES ON testdb.* TO 'username'@localhost;

Select Database

USE testdb;

Create table

CREATE TABLE customers (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);

Load .sql file

source table.sql

Tuning mysql server

sudo apt-get install mysqltuner

Comments

Popular posts from this blog

Proxy setting in java

Using logstash to import csv json files into elasticsearch

Kibana 4 Installation and Run as a service in ubuntu