Category: MySQL

MySQL – Get all sundays in a month

To  get all the Sundays or Saturdays or Mondays you can use the following MySQL code Sunday DAYOFWEEK(DATE_ADD(‘2014-10-01’, INTERVAL ROW DAY))=1 Monday DAYOFWEEK(DATE_ADD(‘2014-10-01’, INTERVAL ROW DAY))=2 Tuesday DAYOFWEEK(DATE_ADD(‘2014-10-01’, INTERVAL ROW DAY))=3 Thursday DAYOFWEEK(DATE_ADD(‘2014-10-01’, INTERVAL...

Hide database from user

Hide database from user

These two queries will restrict a user to a single database, so that the user can only see, update, and delete tables from that single database: Replace USER with the MySQL username Replace USERDATABASE...

PHP Client IP address

PHP Client IP address

Many times we need the visitor’s ipaddress for validation, security, spam prevention, etc. Getting the Visitor’s ipaddress is very easy in PHP. The simplest way to get the visitor’s/client’s ipaddress is using the$_SERVER[‘REMOTE_ADDR’] or $_SERVER[‘REMOTE_HOST’] variables. 1...

Simple shell script to backup MySQL databases

Simple shell script to backup MySQL databases

Simple shell script to backup MySQL databases.

Example output (with mysql password stored inside script):