MySQL shared module extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi (MySQL Improved Extension) or PDO_MySQL extension should be used.

There are three ways to do it:

1.  MySQL shared module

opkg update
opkg install php5-mod-mysql

2. MySQL Improved Extension

opkg update
opkg install php5-mod-mysqli

3. PHP Data Objects plus PDO driver for MySQL

opkg update
opkg install php5-mod-pdo
opkg install php5-mod-pdo-mysql

MySQL shared module sample:

opkg update
opkg install php5-cli
opkg install php5-mod-mysql
nano /mnt/sda1/dbversion.php
#!/usr/bin/php-cli
<?php
$link = mysql_connect("127.0.0.1", "root", "password");
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo "Connected successfully\n";
printf("MySQL server version: %s\n", mysql_get_server_info());
mysql_close($link);
?>
chmod 755 /mnt/sda1/dbversion.php
/mnt/sda1/dbversion.php
Connected successfully
MySQL server version: 5.1.53

MySQL Improved Extension sample:

opkg update
opkg install php5-cli
opkg install php5-mod-mysqli
nano /mnt/sda1/dbversion.php
#!/usr/bin/php-cli
<?php
$link = mysqli_connect("127.0.0.1", "root", "password");
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
/* print server version */
printf("Server version: %d\n", mysqli_get_server_version($link));
/* close connection */
mysqli_close($link);
?>
chmod 755 /mnt/sda1/dbversion.php
/mnt/sda1/dbversion.php
Server version: 50153

PHP Data Objects plus PDO driver for MySQL sample:

opkg update
opkg install php5-cli
opkg install php5-mod-pdo
opkg install php5-mod-pdo-mysql
nano /mnt/sda1/db.php
#!/usr/bin/php-cli
<?php
try {
    $conn = new PDO("mysql:host=127.0.0.1;dbname=test", "root", "password");
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully\n";
    }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }
$conn = null;
?>
chmod 755 /mnt/sda1/db.php
/mnt/sda1/db.php
Connected successfully