Installing PHPMYADMIN on Ubuntu

PhpMyAdmin Installation:-

Phpmyadmin is a tool written over php. it is a free tool to perform administration of mysql over web.It is a Intuitive web interface, support of most of the mysql features like create, browse and drop database, crud operations on tables, manage mysql users and their privileges, manage stored procedures and triggers. Importing data from csv and sql is very easy with phpmyadmin.

To install php myadmin on ubuntu follow these steps

  • Install phpmyadmin

    sudo apt-get update
    sudo apt-get install phpmyadmin -y
  • Setup phpmyadmin to work with local host

    sudo ln -s /usr/share/phpmyadmin /var/www/html
    vim /etc/apache2/apache2.conf
    Include /etc/phpmyadmin/apache.conf

Creating New user in Mysql using command line

Creating New user in Mysql using command line:-

To create a new user using command Line follow these steps.

  • First Login to mysql using root.
    mysql -u root -p
  • Create new user
    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
  • Provide user access
    GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
  • Once you finished with access reload all privileges.

Give Different User Permission

  • ALL PRIVILEGES–  This will give all privileges to user.
  • CREATE– allows users to create new tables or databases.
  • DROP– allows users to delete tables or databases
  • DELETE– allows users to delete rows from tables
  • INSERT– allows users to insert rows into tables
  • SELECT– allows users to use the Select command to read through databases
  • UPDATE– allow users to update table rows
  • GRANT OPTION– allows users to grant or remove other users’ privileges
 GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;

Mysql Commands

Login to Mysql

mysql -u root -p

Mysql restore Dump

mysql -u root -p < path_to_file

use db_name;
source /var/www/html/db.sql

mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]

== export dump ==

mysqldump -u username -p dbname > dbname.sql

== export table dump ==

mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql

== reset mysql password ====

mysql -u root -p
use mysql;
update user set password=PASSWORD('your_new_password') where User='root';
flush privileges;

== dump with where condition ====

mysqldump -t -u root -p  mytestdb mytable --where="datetime LIKE '2014-09%'"

== create database with utf8===

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

== Mysql socket path =====


== restart mysql server ==

/etc/init.d/mysql start