Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Sunday, March 9, 2014

Insert, Update and Delete data in MySQL

Insert New data from PHP


        $SqlCmd = "INSERT INTO SensorStatus ". 
         "(slot_num, bay_num, sensor_status,entry_time) ". 
         "VALUES ". 
         "('$SlotNum','$BayNum1','$SensorStatus',now())"; 
        

        $retval = mysqli_query( $SqlCmd, $conn ); 


Update a data from PHP



          mysqli_query($con,"UPDATE Persons SET Age=36
          WHERE FirstName='Peter' AND LastName='Griffin'");


Delete a Row from Table


mysqli_query($con,"DELETE FROM Persons WHERE LastName='Griffin'")

Thursday, March 6, 2014

Creating New User

    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Give Permissions. I'm giving all the permissions here
    GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
Reload the privileges
    FLUSH PRIVILEGES;






Installing and verifying MySQL

I installed MySQL today (March 06, 2014 )for the first time. It's on Windows 8, 64 bit machine.
We can install it independently, but it is easy to install as a package which contains other things Apache, PHP, etc along with MySQL.

I chose AMPPS, from http://www.ampps.com/downloads
Which contains following things



Includes
Windows
MAC OS X
Softaculous AMPPS
4.4.3
4.4.3
Apache
2.4.7
2.4.7
MySQL
5.6.16
5.6.15
PHP
5.5.9, 5.4.25 and 5.3.28
5.5.9, 5.4.25 and 5.3.28
PERL
5.10.1
5.14.1
Python
2.7.2
2.7.2
MongoDB(64-bit)
2.4.9
2.4.9

I installed it under C:/Server/

Verify that your firewall is not blocking mysql and the port 3036.
Verify in the windows services.
Start a "command prompt" folder in Ampps/mysql/bin
Enter the command

    mysql -u root -p

it will ask for the password. Default password is mysql

It will take you to mysql command prompt.

Type quit to exit to Windows command prompt