Showing posts from August, 2012

Trimming all fields in MySQL database

UPDATE `table1` SET `tbl_column1`= trim(`tbl_column1`);

The above SQL query  will trim all the fields in the tbl_column1

adding user to sudo or admin group in ubuntu

If your system has an admin or sudo group, then we can add the user to that group using the following command.

adduser <username> adminor

adduser <username> sudo.

you should be in sudo or admin login to use the above command

after that if you are not able to get the sudo bash or su -, if you get the below message again

<username> is not in the sudoers file.  This incident will be reported.

Now login to the root user, if you  have permission or boot using Linux resuce CD or boot the PC in recovery mode

1) In root user mode, Type visudo and press enter
this will open /etc/sudoers
add one line...
<username>  ALL = (ALL) ALL

enabling or disabling MySQL log

To see the current status of mysql log, type the following command in XAMPP
SHOW VARIABLES LIKE  'general_log';
below output will come in the phpmyadmin
Variable_nameValuegeneral_logOFF To enable the log, type
SET GLOBAL general_log = 1;
Disabling log
SET GLOBAL general_log = 0;

To check where is the log file saved 
SHOW VARIABLES LIKE  'general_log_file';

Below output will come
Variable_name    Value
general_log_file    \xampp\mysql\data\dino-laptop.log

The log files will be saved in the above mentioned path

disabling signup option in mantis bug tracker

For disabling the signup option in mantis bug tracker , open  the file mantis/config_inc.php

add the below line

 $g_allow_signup configuration = OFF; 

save the file. After this, int he mantis login page, there wont be option for new user signing up.

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 89 bytes)

In my php script, i was  not able to get page view, the page was having lot of variables.  and some was taking lot since it was in foreach loop updating a big table output.

debugging foudn that, it was due to memory was not sufficient for the php to allocate.
In the php.ini we cam increase the memory with the  memory_limit = 128M configuration. After increasing the size form 128M to 256M, mine was working fine.

But i think i should re design the webpage as php consuming this much memory is not good in long term. There will be better way to reduce it .