MySQL Database

    How to install php on AWS EC2 instance with Amazon MySQL RDS On Ubuntu

    Execute this command: (Remove which you don't need)

    ubuntu@mohitsharma.net$: sudo apt-get install apache2 libapache2-mod-php5 php5-mysql postfix mysql-client unzip php5-memcache php5-curl memcached php5-gd

    How to install phpmyadmin with php7 on ubuntu 14.04

    Go to directory /usr/share :$ cd /usr/share Download PhpMyAdmin there :$ sudo wget "https://files.phpmyadmin.net/phpMyAdmin/4.5.4.1/phpMyAdmin-4.5.4.1-all-languages.zip" Unzip content :$ sudo unzip phpMyAdmin-4.5.4.1-all-languages.zip Rename Directory :$ sudo mv phpMyAdmin-4.5.4.1-all-languages phpmyadmin Give Recursive permission for execution :$ sudo chmod -R 0755 phpmyadmin Add phpmyadmin to apache2 default configuration file :$ sudo vim /etc/apache2/sites-available/000-default.conf Add below lines after DocumentRoot Alias /phpmyadmin "/usr/sha

    How to install Drupal on PHP7 and Upgrade Server on Ubuntu

    Follow these steps:
    Step 1: sudo add-apt-repository ppa:ondrej/php-7.0

    Step 2: sudo apt-get update
    With Apache:
    Step 3: sudo apt-get install php7.0

    Step 4: sudo apt-get install php7.0-mysql

    Step 5: sudo service apache2 restart
    With Nginx PHP-FPM
    Step 3: sudo apt-get install php7.0-fpm

    Step 4: sudo apt-get install php7.0-mysql

    Step 5: sudo nano /etc/nginx/sites-enabled/default

    Change fastcgi_pass unix:/var/run/php5-fpm.sock; to  unix:/var/run/php/php7.0-fpm.sock;

    Step 6: sudo service nginx restart

    How to create new user in mysql

    To create new user in mysql. Login to mysql and run following commands:
    mysql> CREATE USER 'mohitsharma'@'localhost' IDENTIFIED BY 'secretpassword';

    mysql> GRANT ALL PRIVILEGES ON * . * TO 'mohitsharma'@'localhost';

    to grant specific permission to table to database will be covered in other chapter


    mysql> FLUSH PRIVILEGES;

    mysql> exit

    $: mysql -u mohitsharma -p and Enter
    Easy & Done :)

    How to start mysql console on mac MAMP

    To start mysql console on mac MAMP you can open the terminal and issue this command
    Terminal$: /Applications/MAMP/Library/bin/mysql --host=localhost -u root -p root

    How to delete duplicate values in a column in mysql table

    You can delete duplicate values in column using below query replace the tablename and fieldname before using it
    DELETE temp1.*
    FROM cities AS temp1
       INNER JOIN (
          SELECT city
          FROM cities
          GROUP BY city
          HAVING COUNT(*) > 1
       ) AS temp2 ON temp2.city = temp1.city

    How to show table collation on mysql command line

    To show table collation on mysql command line use following command
    mysql> show table status;

    How to import mysql dump in mac

    Open terminal and enter below command with path to the dump file
    apples-MacBook-Pro:~ apple$ /Applications/MAMP/Library/bin/mysql -u username -p databasename < "pathtodumpfile.sql"

    How to start mysql terminal in Mac Ox

    Open terminal and execute following command

    /Applications/MAMP/Library/bin/mysql -uroot -p

    Enter password if any your mysql console will be started then