Archive

Archive for the ‘MySQL’ Category

What is the advantge and disadvantage of mysql_connect() and mysql_pconnect() ?

April 16th, 2009 No comments

mysql_pconnect() will maintain a persistent connection to the database. Whenever your script calls the connect to database function, it first searches already existing connections to the database and if exists it will use the same connection to connect to the database, if not it will open a new connection to the database. ie. Connection is Persistent

where as mysql_connect() function will establish a new connection whenever a connection to database needed, and after executing the script, this function disconnects the connection. ie. connection is not a persistent one.

mysql_pconnect() function is used where your site has a Heavy Traffic and where as mysql_connect() function is used when there is moderate/less traffic to your site.

Regard’s

Alex P

System Administrator.

Mysql error : Can’t create new tempfile: ‘*.TMD file

April 6th, 2009 6 comments

Hello,

If you are getting Can’t create new tempfile: ‘tablesname.TMD file error while repairing corrupted database tables please try use following command to fix it

Solution.

# myisamchk -r -f  tables.MYI

Regard’s

Stacy.

Categories: MySQL Tags: ,

How do you repair a corrupt MySQL table?

March 22nd, 2009 3 comments

Hello,

Error: Table ‘tbl_ name’ doesn’t exist databasename_tablesname.frm can’t open

If you get either of the following errors, it usually means that no table exists in the current database with the given name:

Table ‘tbl_name’ doesn’t exist

Can’t find file: ‘tbl_name’ (errno: 2)

A ) In some cases, it may be that the table does exist but that you are referring to it incorrectly:

Because MySQL uses directories and files to store databases and tables, database and table names are case sensitive if they are located on a file system that has case-sensitive filenames.Even for file systems that are not case sensitive, such as on Windows, all references to a given table within a query must use the same letter case.

B ) In some cases, it may be that the table exist but same error occurs then

1 ) Check the permission and ownership of database i.e. it should be same below

drwx—— 2 mysql mysql cpanelusername_dbname.

2) If the permission are corrects but same error occurs then it seems that your database table may be corrupts then there are following way to repair the DB

a) Go to whm >>SQL Services >> Repair a Database >> select database name and click Repair Database.

b) Go to cpanel >> mysql section MySQL Account Maintenance >> search database then click on Repair.

C) You can repair it though shell when mysqld server is running

i) login in mysql to that particular user by using following command

mysql>mysql –u databaseusername –p databasename

ii) select particular database

mysql> use databasename;

iii) Check whether database table is corrupted or not if following command output shows null value then it should be corrupts otherwise it is fine

mysql>show table status like ‘table name’\G; Or
mysql>check table tablename ;

iv)If it is corrupts then use the following command to repair that particular database table.

mysql>repair table tablename;

D] You can repair it though shell when mysqld server is not running

Repairing MyISAM mySQL Tables/Databases:

# cd /var/lib/mysql/DBNAME

# myisamchk tablename.MYI

Repairing ISAM mySQL Tables/Databases:

# cd /var/lib/mysql/DBNAME
isamchk tablename.MYI

where

-c –> check database is corrupted or not
-r –> recorver
-o –> optimise the database

Regards

Alex P