Archive

Posts Tagged ‘Mysql’

Connect Mysql from git on windows

December 16, 2016 Leave a comment

We can connect to mysql from git on window through this command.

winpty mysql -uROOT -pPASSWORD

Advertisements
Categories: Mysql Tags: , , , ,

MongoDb Introduction

April 7, 2016 Leave a comment

MongoDB Databse-
MongoDB is NoSql and document oriented database. MongoDB stores data using a flexible document data model that is similar to JSON.

Create Database-
>use yaju;

Show Database-
>show dbs

Drop Database-
To drop database, first use that database then use following command.
>db.dropDatabase();

Create Collection-
Collections are like table in MySql. We can create collection in two ways.

First, we can create empty collection
>db.createCollection(‘test’);

Second, we can create dynamic collection with insert command. Mongo check that collection if collection is exists then insert data in existing collection otherwise create new collection and insert data. That can be through followning command.
>db.testtable.insert({‘name’:’yajuvendra’},{‘name’:’yaj’});

Show collections-
Show all collection in a database use following command.
>show collections;

Insert document-
We can insert single document and multiple document as well.

Single document
>db.testtable.insert({‘name’:’yajuvendra’},{‘name’:’yaj’});
Multiple document
>db.testtable.insert([{‘name’:’yajuvendra’},{‘name’:’yaj’}, {‘name’:’yaju’},{‘name’:’yajkumar’}]);

Select document-
Select all document
>db.testtable.find();
Select particular document
> db.testtable.find({‘name’:’yaj’});

Remove document-
> db.testtable.remove({‘name’:’yaju’});

Update document-
> db.testtable.update({name:’yaj’},{$set:{name:’yaju_update’}})

Mysql Important

November 3, 2015 Leave a comment

 

#Login to mysql
mysql> -hlocalhost -P3306 -u{user name} -p

#Select Current User
mysql bin folder>select user();
Output-
+—————-+
| user() |
+—————-+
| root@localhost |
+—————-+
1 row in set (0.00 sec)

#Select Mysql Version
mysql bin folder>select version();
Output-
+———–+
| version() |
+———–+
| 5.6.17 |
+———–+
1 row in set (0.00 sec)

#Select Current Database
mysql bin folder>select database();
Output- These is not database selected.
+————+
| database() |
+————+
| NULL |
+————+
1 row in set (0.00 sec)

#Select Current date with Hour Minute and Second
mysql bin folder>select now();
Output-
+———————+
| now() |
+———————+
| 2016-04-04 12:52:55 |
+———————+
1 row in set (0.00 sec)

#Select Current date, shows only date.
mysql bin folder>select now();
Output-
+—————-+
| current_date() |
+—————-+
| 2016-04-04 |
+—————-+
1 row in set (0.00 sec)

#Export database or table
mysql bin folder>mysqldump -hlocalhost -P3306 -u{username} -p{password} {database name} {table name} > export file path/filename.sqlpath/filename.sql

#Import database or table
mysql bin folder>mysql -hlocalhost -P3306 -u{username} -p{password} {database name} {table name} < import file path/filename.sql

VIEW
Create: mysql>create view {view name} as select * from {table name};
View: mysql>show full tables;
mysql>show full tables in {database name} table_type like ‘view’;
Drop: mysql>drop view {view name};

TRIGGER
Create:
mysql>delimiter //
mysql> create trigger {trigger name}
after insert
on {table name} for each row
begin
insert into {table name} values(”, new. {new value});
end;//
mysql>delimiter ;

View:
mysql>show triggers;

Drop:
mysql>drop trigger {trigger name};

STORED PROCEDURES
Create:
mysql>delimiter //
mysql>create procedure {procedure name}(in inputvalue int, out outputvalue int)
begin
outputvalue = inputvalue;
end; //
mysql>delimiter ;

Call:
mysql>call {procedure name}(inputvalue, @output);
mysql>select @output;(result 100);

View:
mysql>show procedure status;

Drop:
mysql>drop procedure {procedure name};

STORED FUNCTIONS
Create:
mysql>delimiter //
mysql>create function {function name}({parameter name} {data type})
returns {data type}
begin
declare {variable name} {data type};
select {variable name} into {paramerter name} from {table name} where id={parameter name};
return ({variable name});
end; //
mysql>delimiter ;

 

Categories: Mysql Tags: , , , , ,

Speed up site with .htaccess

January 20, 2015 1 comment

Append these line in your .htaccess file.

#Trun on compression

mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

#Turn on content caching

ExpiresActive On
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”
ExpiresByType text/x-javascript “access plus 1 month”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 month”

ExpiresByType application/font-woff “access plus 1 month”
ExpiresByType application/vnd.ms-fontobject “access plus 1 month”
ExpiresByType application/x-font-ttf “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType image/svg+xml “access plus 1 month”

ExpiresDefault “access 2 days”
Header set Cache-Control “public”
Header unset Cache-control

Header append Vary: Accept-Encoding
Header unset Pragma

#Mod_deflate is an apache module that can be used to compress data using gzip compression before sending it to the browser

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/x-font-ttf

Install PhpUnit

March 7, 2014 1 comment

Run the Windows Command Processor (cmd.exe).
Run >pear channel-discover pear.phpunit.de
Run >pear remote-list -c phpunit
You will see a similar screen:
CHANNEL PHPUNIT AVAILABLE PACKAGES:
===================================
PACKAGE VERSION
DbUnit 1.3.0
Diff 1.1.0
Exporter 1.0.0
File_Iterator 1.3.4
FinderFacade 1.1.0
Git 1.2.0
PHPUnit 4.0.1
PHPUnit_MockObject 1.2.3
PHPUnit_Selenium 1.3.3
PHPUnit_SkeletonGenerator 1.2.1
PHPUnit_Story 1.0.2
PHPUnit_TestListener_DBUS 1.0.0
PHPUnit_TestListener_XHProf 1.0.0
PHPUnit_TicketListener_Fogbugz 1.0.0
PHPUnit_TicketListener_GitHub 1.0.0
PHPUnit_TicketListener_GoogleCode 1.0.0
PHPUnit_TicketListener_Trac 1.0.0
PHP_CodeBrowser 1.0.2
PHP_CodeCoverage 1.2.16
PHP_Invoker 1.1.3
PHP_Timer 1.0.5
PHP_TokenStream 1.2.2
Text_Template 1.2.0
Version 1.0.2
bytekit 1.1.3
phpcov 1.1.0
phpcpd 2.0.0
phpdcd -n/a-
phploc 2.0.4
test_helpers 1.1.0
Run >pear install phpunit/PHPUnit-4.0.1
You will see a similar screen:
downloading PHPUnit-4.0.1.tgz …
Starting to download PHPUnit-4.0.1.tgz (510,701 bytes)
….done: 510,701 bytes
install ok: channel://pear.phpunit.de/PHPUnit-4.0.1

Install PHP Mess Detector

March 7, 2014 1 comment

Run the Windows Command Processor (cmd.exe).
Run >pear channel-discover pear.phpmd.org.
Run >pear channel-discover pear.pdepend.org.
Run >pear install phpmd/PHP_PMD-1.5.0. You will see a similar screen:

Did not download optional dependencies: pecl/imagick, use –alldeps to download
automatically
pdepend/PHP_Depend can optionally use package “pecl/imagick” (version >= 2.2.0b2
)
downloading PHP_PMD-1.5.0.tgz …
Starting to download PHP_PMD-1.5.0.tgz (49,534 bytes)
………….done: 49,534 bytes
downloading PHP_Depend-1.1.4.tgz …
Starting to download PHP_Depend-1.1.4.tgz (179,584 bytes)
…done: 179,584 bytes
install ok: channel://pear.pdepend.org/PHP_Depend-1.1.4
install ok: channel://pear.phpmd.org/PHP_PMD-1.5.0

Joomla 3.x component creator

August 16, 2013 Leave a comment

Create Component Joomla 3.x

%d bloggers like this: