12 Feb 2018

MySQL script for Performance tuning

What is MySQL performance tuning and what does it mean ?

MySQL has a lot of variables in its configuration. We can edit and set/alter variables to our requirements on our server. We can improve the MySQL performance by varying those values in configuration file. A lot of methods and shell scripts are available for tuning your MySQL server. Here I am explaining the installation and usage of one shell script for tuning the MySQL.

This performance tuning shell script will help you to optimize your MySQL server on a huge traffic cPanel server.

Installation steps

The MySQL tuner has simple installation steps. You can download the latest version from HERE.

Step I : SSH to your server as root user.
Step II : wget the latest version.

wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh

Step III : Change the file permission as executable.

chmod 755 tuning-primer.sh

Step IV : Execute the script.

./tuning-primer.sh

See the attached image which has a sample tuner output.

That’s it 🙂

06 Feb 2018

Script for checking MySQL database connection from web-browser

It’s very simple and interesting to check the MySQL database connectivity from your account without login as a root. Here is a script to do the same.  For checking the database connectivity, you must know the database hostname, normally it is “localhost” then database-name, username and password.

PHP Code:

<?php
mysql_connect('db_host', 'db_username', 'password') or die('Could not connect the database : Username or password incorrect');
mysql_select_db('db_name') or die ('No database found');
echo 'Database Connected successfully';
?>

It’s very simple concept, first the “mysql_connect” argument will check the database hostname, username and password. If the first argument is true, then PHP take the second line to execute else the script will die with an output given in the Die section. Similarly, mysql_select_db check the database on the server. If both of the arguments are true then you will get an output given after the echo command

Example:

1, If all of the input data(db_name, username, password, hostname) are right, then the output is like;

Database Connected successfully

2, If any of the entry in ‘mysql_connect’ secion is wrong, then the output is;

Could not connect the database : Username or password incorrect

3, If the database entry is wrong;

No database found

That’s it 🙂

23 Nov 2017

Upgrading MySQL from 5.1 to 5.5 in a cPanel server

MySQL is an open source RDBMS (Relational Database Management System) and its using the SQL Language(Structured Query Language). A database is a structured collection of data. SQL is the most commonly using language for database operations. By using SQL the database operations like adding, accessing and managing the database is very simple.

The MySQL upgrading steps is quite difficult normally. Like all software, the first steps for MySQL upgrade is taking the backup. Yes! it’s a very important step. In a cPanel installed server you can upgrade the MySQL version from the command line itself by using the script “/scripts/check_cpanel_rpms”.

Here is short look for upgrading your MySql from 5.1 to 5.5 in a cPanel server.

1. Take the backup of all the databases on the server.

2. Replace the MySQL version from 5.1 with 5.5 in /var/cpanel/cpanel.config file

#vi /var/cpanel/cpanel.config
and then, change 
-------
"mysql-version=5.1" to "mysql-version=5.5".
-------

3. Then, run

#/scripts/check_cpanel_rpms --fix
 4. After executing this command, try

#mysql -V

MySQL will be upgraded to 5.5. Then try, php -v. You will get the following error:

-------------------
[email protected] [~]# php -v
php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
--------------------

Do an easyapache to fix this.

#/scripts/easyapache

Done!

©2021 Tranzmedia Netvision Limited. All Rights Reserved.
Top