Archive for the ‘MySQL’ Category



How to repair MySQL table from SSH

Saturday, March 28th, 2009

If you are getting an MySQL related error on your site for any database, you can repair the database through SSH from MySQL prompt.

For example:

Invalid SQL: SELECT * FROM `something` WHERE `id` = '151' ORDER BY `someid` ASC LIMIT 0,20; (Can't open file: 'sometable.MYI' (errno: 145))

Login to your server as root.

Firstly check the status of MySQL on your dedicated server. Normally, it should be ok – as you’re getting this error.

The database table can be repaired only if the Mysql server is in running status. You can check the status by the command.

root# /etc/init.d/myssql status

Now, login to the MySQL database for a required user.

mysql> mysql –u databaseusername –p database password databasename

You need to select that particular database having problem.

mysql> use databasename;

Now, you will have to check whether the table is corrupted. On giving the below command you will get a NULL value as your output if it is   corrupted otherwise it’s alright.

mysql> check table tablename;

If the table is corrupted for that particular database, then you need
to repair the table by giving the following command.

mysql> repair table tablename;

This will repair the table for you.
This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.


Remote access to MySQL on cPanel server

Wednesday, May 14th, 2008

For users who may wish to access a MySQL database from a remote location. You need to know the basics that MySQL uses port 3306. It is assumed that you already have a database under your cPanel hosting account. To ensure you can connect remotely you will also need to add the relevant Access Host.

Now, you have to grant permissions for this click on “MySQL database” icon under cPanel. When you scroll down you will see heading “Access Host” the default host is “localhost” which you can see over there. In the box there you can add the IP address that you want to allow connection from.

If you want all IP addresses within a range to work you can use a wildcard (%) symbol, for example:

192.168.1.% will allow any user from 192.168.1.1 to 192.168.1.255 to connect.

The wildcard symbol on its own will allow any user to connect, assuming that they have the username and password for a database.

That’s it!

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.


Monitor MySQL processes on linux server

Tuesday, May 6th, 2008

If you need to monitor MySQL and want to see the database used at that particular time, as well as the state and time you can use the following command to check it:

root@server# mysqladmin processlist

Or

root@server# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 121572 to server version: 4.1.22-standard

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> SHOW FULL PROCESSLIST;

That’s it!

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.


Import and export mysql database

Friday, May 2nd, 2008

On a cPanel server, if you need to import a SQL file into a database – here is the command to get this done:

mysql cpanelusername_database < sqlfilename.sql

And, if you want to export the database to a sql file – the command to do this is:

mysqldump cpanelusername_datbase > databasename.sql

That’s it!

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.


Downgrade MySQL 5 to MySQL 4.1 on cPanel dedicated server

Friday, April 18th, 2008

For some reason you need to downgrade MySQL 5 to MySQL 4.1 to achieve this you will have to do the following:

To check the which all mysql rpm’s are available use the command:

rpm -qa | grep -i mysql-

First of all take a backup of /var/lib/mysql, and also ask the other users to keep a backup it with them. This can also be a .sql file. The command to take a backup is:

cp /var/lib/mysql /var/lib/mysql.bk

Now, you will have to edit the cPanel config file and make manual changes under this, so edit it with the command:

nano /var/cpanel/cpanel.config

And here, find for the line “mysql-version=5.0” and change it to “mysql-version=4.1

Now, we will forcefully install mysql by the following command:

/scripts/mysqlup --force

You can now check again with the command:

rpm -qa | grep -i mysql-

This is done and worked for me.

Let us know if this has helped you and have any suggestions on this.

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.