Feb 22, 2013 | MySQL, Ubuntu 12.04 Server Management
Oops! I’ve forgotten MySQL root password. 1)Stop MySQL instance (if it is running) sudo service mysql stop 2)Startup MySQL instance manually with option –skip-grant-tables and –skip-networking sudo mysqld_safe --skip-grant-tables --skip-networking 3)While MySQL is running from step 2, login to MySQL mysql --user=root mysql 4)Execute the following SQL commands to update root password Update user set Password=PASSWORD('new-password') where user='root'; flush privileges; exit; 5)Remember to stop MySQL instance executed from step 2 after you complete step 4. Lastly run MySQL normally. sudo service mysql...
Aug 30, 2012 | date and time, PHP
“I need to store birthdate of my customers where it can fall before year 1970.” Php function date(), strtotime() uses UNIX timestamp which supports year 1970 to 2038. To work with date values beyond that, we need to use php datetime class which is available on after php version 5.2.0 (datetime manual). Create a date before 1970: $dt = new DateTime(); $dt->setDate(1945, 8, 8); // August 8 1945, end of world war 2 If you need to store time as well: //public DateTime DateTime::setTime ( int $hour , int $minute [, int $second = 0 ] ) //seconds argument is optional $dt->setTime(8,0,45); // 8:00:45 am To print the date: echo $dt->format('Y-m-d H:i:s'); //outputs //1945-08-08 08:00:45 For list of date format to use, refer to http://php.net/manual/en/function.date.php. Hope it helps....
Aug 27, 2012 | Apache Server, htaccess
You are developing a new site and wish to keep it secret till your new site is ready for launch? You got personal photos, confidential documents, project codes uploaded to your web server for future reference or download and you want to give access only to certain people? One of the solutions is to password protect your directory where the restricted stuffs were stored. “How to password protect the directory or entire website?” Requirements: – Hosted on apache server – Apache module mod_access is enabled. Step 1 Create password file “.htpasswd”. In the folder / site root you wish to password protect, create a .htpasswd file. The password file stores your valid users’ username and password. Step 2 Use online passwd generator to create user’s username and password entry for htpasswd. http://www.htaccesstools.com/htpasswd-generator/ Copy and paste the entries into “.htpasswd”. Example of an .htpasswd file denny:$apr1$7APPNnCz$M./pcs91u296uBP0VAD4J1 Step 3 In the same folder, create/edit .htaccess to include the following codes. AuthUserFile /absolute/path/to/.htpasswd AuthType Basic AuthName "Prompt Title" Require valid-user Note: Relative path to .htpasswd will not work. Final Step Launch your browser, navigate to the password protected folder, you will receive a authentication challenge if nothing goes wrong. =D That’s...