Jump to content

Locking tables question


RobertSubnet

Recommended Posts

Hello all. I am attempting to use PHP to lock a MySQL table that uses a myisam engine. The code I am using is as follows:

 

mysql_query("LOCK TABLES stuff4sale WRITE;");

 

But when executing a show open tables from the command line I see that the table does not get locked. I can lock and unlock the table just fine from the command line but not when using PHP. This should be pretty simple but obviously I am missing something. Prior to running the PHP I have confirmed a working connection to the database.

 

What am I missing?

 

Thank you for your time and comments.

Link to comment
Share on other sites

I think I have finally found the answer: skip_locking or in this case skip_external_locking is set to on.

 

Now I am trying to figure out how to enable external locking; my my.cnf file has the following:

 

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
enable-locking
external-locking

 

Save and restart the mysqld service and skip_external_locking is still set to on. Any ideas on why the my.cnf is not turning off the skip_external_locking?

 

Thanks.

Link to comment
Share on other sites

Well I am not sure how to display the output from show open tables using PHP but I did use a sleep() just after locking the tables from PHP. Checking the command line and sure enough the table was locked. So Kicken it looks like you were correct once the script ended the lock released.

 

Thank you all for your help!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.