Dump single able to file

Just enter the file name and the table name and the table will be backed up to the file.

1
mysql_query("SELECT * INTO DUMPFILE './file-name.sql' FROM `table-name`");

copy all files to new destination recursively with ssh

Copies destination files to the current location on the server.
Parameters make it recursive and overrides current files.
Trailing dot, specifies the current location, it can be a pass
to a different dir on the server.

cp -Rf /source/containing/all/files/* .

get file name from url

Get the file part of a url.
turns the url into an array and then gets the last element of the array.

1
$file = end( explode('/', $url) );

MySQL Database Import via Command Line

This SSH command executes a batch file into the specified database.

mysql -p -u username database_name < file.sql

Facebook Debgger

Facebook Debuging tool. Userful for clearing cache.

http://developers.facebook.com/tools/debug

reset mysql auto increment

The number you set will be the next value
—————–
ALTER TABLE `node` AUTO_INCREMENT=1

remote mysql database synch

Syncronize local database with remote one:
——————————————
ssh user@www.domain.com “mysqldump -u remoteUsername –password=remotePassword remoteDBName” | mysql -u localUsername –password=localPassword –host=localhost -C localDBname

Syncronize remote database with local one:
——————————————
mysqldump -u localUsername –password=localPassword –host=localhost -C localDBName | ssh user@www.domain.com “mysql -u remoteUsername –password=remotePassword remoteDBName”

Code Igniter Direct Access blocking

Prevent direct access to php file.
This line does a simple check to see if the BASEPATH is defined. It doesn’t check where it was define ( possible security issue, but should be no big deal.)

1
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

start mysql server

/etc/rc.d/init.d/mysqld start

install apache mysql php

Install the AMP in LAMP
sudo yum install httpd php mysql-server mysql