Month: March 2007

How to Transfer account on cPanel Server –

How to Transfer account on cPanel Server –

Introduction – Many times System Admin want to transfer cPanel user account (domain) from one cPanel server to other cPanel Server. cPanel allows to do account transfer via WHM as follows… (you should have  root access to both server).

step(1) Login to WHM
step(2) then Main menu >> Transfers >> Copy multiple accounts/packages from another server

Here you need to provide the old server IP, SSH port, and root password.

That’s it!. your account will be transfer to new server…

If the above method fails due to some or other reason, you can transfer accounts manually as follows….

step(1) Take backup of the accounts using the following script –

root@arunbagul:~# /scripts/pkgacct  <account username>

This will create a backup file under /home with name cpmove-<username>.tar.gz

for example –

root@arunbagul:~# /scripts/pkgacct indgnu

….
root@arunbagul:~#

root@arunbagul:~#  ls /home/cpmove-indgnu.tar.gz

step(2) Copy(use scp) this file into the new target server where you want to migrate your account –

root@arunbagul:~# scp /home/cpmove-<username>.tar.gz root@<new server ip>:/home/
….
……
root@arunbagul:~#

step(3) Restore accounts using the following script (on new target server) –

root@arunbagul:~# /scripts/restorepkg <account username>

NOTE:- Make  sure that the account on old server is disabled or removed/suspended!!

Cheers,
Arun  Bagul

PHP and FTP

PHP and FTP

Introductions –

PHP provides FTP library to connect to file server using File Transfer Protocol. No external libraries are needed to build this extension. In order to use FTP functions with your PHP configuration, you should add the –enable-ftp or –with-ftp option when installing PHP 5 and other versions. The windows version of PHP has built in support for this extension. You do not need to load any additional extension in order to use these functions…

** Once the installation is done you can check by executing the below script –

URL – http://localhost/phpinfo.php

<?php

phpinfo(); // show the information of php.ini

?>

phpinfo-ftp

Using PHP we can make web interface which will do the entire file upload, download and execute shell commands on remote server. We can make Web FTP client using PHP FTP library.

examples –

How to upload file using PHP-FTP function –

<?php
// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
echo “FTP connection has failed!”;
echo “Attempted to connect to $ftp_server for user $ftp_user_name”;
exit;
} else {
echo “Connected to $ftp_server, for user $ftp_user_name”;
}

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
echo “FTP upload has failed!”;
} else {
echo “Uploaded $source_file to $ftp_server as $destination_file”;
}

// close the FTP stream
ftp_close($conn_id);
?>

Thank you,
Santhosh Tirunahari

ORACLE Application Express

ORACLE Application Express

ORACLE Application Express –

Application Express is the open source product by ORACLE. Every one knows HTMLDB, which is used for web representation of oracle database data. Now HTMLDB renamed as Application Express. We can use Oracle forms and reports for data representation. But application express got many good features, which makes web interface very user friendly. Now Apex 3.1 is released.

Features of Apex 3.1 –
1) Web 2.0 functionalities are used.
2) Ajax, Javascript, CSS, DOM used extensily when showing the reports in effective manner. Now the reports are user friendly.
3) Improved PDF document reports downloads and printing.
4) Mailing with Attachments features made effectivly.
5) Customization is possible in reports.

Thank you,
Santhosh Tirunahari

Indexes in MySQL

Indexes in MySQL

Managing Indexes in MySQL –

Index is a method/process that MySQL uses to speed up searches and reduce the time it takes to execute complex queries. Index provides an organized list of pointers to the actual data. Due to indexing, when MySQL is executing a query, it does not have to scan each table in its entirety to locate the correct data, but it can instead scan the index, which results in quicker and more efficient access…

MySQL supports five type of indexes that can be created on a table….

1) Primary Key – The value or set of values should be unique in the columns on which the primary key is defined. NULL value is not allowed. Table can include only one primary key.

2) Foreign Key – Enforces the relationship between the referencing columns in the child table where the foreign key is defined and the referenced columns in the parent table.

3) Regular – A basic index that permits duplicate values and null values in the columns on which the index is defined…

4) Unique – Requires that each value or set of values be unique in the columns on which the index is defined. Unlike primary key indexes,null values are allowed.

5) Full-text – Supports full text searches of the values in the columns on which the index is defined. A full text permits duplicate values and null values in those columns. A full-text index can be defined only on MyISAM tables and only on CHAR, VARCHAR columns…

How to create indexes –

(a) In below query for creating table. We are defining two indexes one primary key and other is unique.

mysql> CREATE TABLE market (orderID INT(5), modelID INT(5), Name VARCHAR(40), PRIMARY KEY(orderID), UNIQUE (orderID,modelID));
Query OK, 0 rows affected (0.00 sec)

mysql>

(b) In below query for creating table. We are defining Regular indexing

mysql> CREATE TABLE market (orderID INT(5), Name VARCHAR(40), INDEX(orderID) );
Query OK, 0 rows affected (0.00 sec)

mysql>

(c) How to add indexes to existing table –

mysql> CREATE TABLE market (orderID INT(5), Name VARCHAR(40));
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER TABLE market ADD PRIMARY KEY (orderID);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql>

(d) How to create index by using “CREATE INDEX” –

mysql> CREATE TABLE market (orderID INT(5), Name VARCHAR(40));
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE INDEX myindex ON market (orderID);
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql>
** How to drop index –

mysql> DROP INDEX myindex ON market;
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql>

(e) How to get information about your Databases and tables –

** Below SQL commands can be used to view the database definition for specific database.

mysql> SHOW CREATE DATABASE zabbix;
+———-+——————————————————————-+
| Database | Create Database |
+———-+——————————————————————-+
| zabbix | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+———-+——————————————————————-+
1 row in set (0.00 sec)

mysql>

** SQL command to view table definition

mysql> SHOW CREATE TABLE market;
+——–+———————————————+
| Table | Create Table |
+——–+———————————————+
| market | CREATE TABLE `market` (
`orderID` int(5) default NULL,
`Name` varchar(40) default NULL,
KEY `myindex` (`orderID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+——–+———————————————+
1 row in set (0.00 sec)

mysql>

** How to describe the table structure –

mysql> SHOW COLUMNS FROM market;
+———+————-+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+———+————-+——+—–+———+——-+
| orderID | int(5) | YES | | NULL | |
| Name | varchar(40) | YES | | NULL | |
+———+————-+——+—–+———+——-+
2 rows in set (0.01 sec)

mysql> DESC market;
+———+————-+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+———+————-+——+—–+———+——-+
| orderID | int(5) | YES | | NULL | |
| Name | varchar(40) | YES | | NULL | |
+———+————-+——+—–+———+——-+
2 rows in set (0.00 sec)

** How to views indexes defined on perticular table –

mysql> SHOW INDEX FROM market;
Empty set (0.00 sec)

mysql> CREATE INDEX myindex ON market (orderID);
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> SHOW INDEX FROM market;
+——–+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+——–+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+
| market | 1 | myindex | 1 | orderID | A | NULL | NULL | NULL | YES | BTREE | |
+——–+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+
1 row in set (0.00 sec)

mysql>

Thank you,
Arun Bagul