Monday, October 28, 2013

[MySQL] - Host 'xxx.xxx.x.xx' is not allowed to connect to this MySQL server

This problem happen when the mysql server doesn't allow remote connection. So first, go to the mysql server that you want to access.
  • Use putty (for windows) or terminal (for unix/linux) and perform the ssh
    ssh root@xxx.xxx.x.xx
    Enter password: (enter the server's password) 
  • Then type:
    mysql -u root -p
    Enter password:(enter the mysql password) 
  • Then type the following command:
    GRANT ALL PRIVILEGES ON *.* TO your_mysql_user@'%' IDENTIFIED BY 'your_mysql_password';
* make sure you change the value of your_mysql_user and your_mysql_password.Now you can access the mysql server through remote connection.

Friday, October 25, 2013

[Centos] - Yum with proxy

Just add the following on environment variable in .bash_profile file:

export http_proxy=http://ip:port

Now you can yum as usual.

Tuesday, October 1, 2013

[PHP] - Encode / Decode paramater on the URL using base64


function my_base64_encode($input) {
	return strtr(base64_encode($input), 'AEIOUj', '+-_,');
}
 
function my_base64_decode($input){
	return base64_decode(strtr($input, '+-_,', 'AEIOUj'));
}

$texttoencode = 'RAIHAN';

$b = my_base64_encode($texttoencode);
// the value of $b now is UkFJS-F,

$c = my_base64_decode($b);
// the value of $c is RAIHAN


Friday, September 20, 2013

[Linux] - Copy and exclude certain folder

Let say you have a folder structure like below:
  • source
    • folder_video
      • videoA.mpg
      • videoB.mpg
      • videoC.mpg
    • folder_contents
      • file1.txt
      • file2.txt
    • folder_picture
    • fileA.txt
    • fileB.txt
    • folder_documents
     
You want to copy all contents on the source folder and at the same time exclude certain folder. How? Follow the below instruction.

Exclude single folder

rsync -avz --exclude folder_video /source /your_destination_path

* it will copy the source folder to your_destination_path and exclude the folder_video

Exclude multiple folder

rsync -avz --exclude folder_video --exclude folder_contents /source /your_destination_path

* it will copy the source folder to your_destination_path and exclude the folder_video and folder_contents

Exclude file and folder at a same time

rsync -avz --exclude folder_video --exclude folder_contents/file1.txt /source /your_destination_path

* it will copy the source folder to your_destination_path and exclude the folder_video and file1.txt

Monday, April 29, 2013

[SVN] - Add SVN user

Tested on Centos

Add new user account (for first time)
htpasswd -cm /etc/.svn-auth-file <username>
* It will ask for password. Provide the password and confirm again.

Add another user in the same svn-auth-file
htpasswd -m /etc/svn-auth-users <username>
or
htpasswd -m /etc/svn-auth-users <username> <password>

[Linux] - How to list linux file/folder permission on numerical value

Tested on Centos and Ubuntu.

stat -c "%a %n" *

Sample output:

777 aircrack-ng-1.1
755 abc.txt
644 root.conf