Welcome to Geeklog, Anonymous Friday, July 12 2024 @ 05:10 pm EDT

Question: comment.php error: can not lock table gl_comments

Answer: You might see this message in your error.log:

1044: Access denied for user: 'xxx@%' to database 'xxx'. SQL in question: LOCK TABLES gl_comments WRITE

Possible solutions:

0. Hosted Environment: Tell your host that you want "LOCK TABLE" priveleges or you'll take your business else where. Some hosting providers will stall or say they can't set it for reason XXX. That is just not true. Most hosts provide this capability.

1. If you have mysql administrative privileges to grant database level rights (usually this requires being the mysql root user) use the following SQL to grant lock table privileges:
GRANT LOCK TABLES ON <database_name>.* to <user>@<host>

2. Remove all the "LOCK TABLE" and "UNLOCK TABLE" (DB_lockTable / DB_unlockTable as of Geeklog 1.4.1) SQL calls from system/lib-comment.php (or from comment.php, on earlier Geeklog versions). This should be okay if you have a low traffice site, but opens up the possiblity of corruption if two or more users try to save or delete comments at the same time.

3. Upgrade to InnoDB tables. There is a script in the admin directory to do this. Then, in system/lib-comment.php, change every instance of "LOCK TABLE XXX" to "START TRANSACTION" and every instance of "UNLOCK TABLE XXX" to "COMMIT". The only downside to this is that it is not well tested and will only work with InnoDB tables.

Grant Privileges Syntax
Lock Tables Syntax

Hits: 239

FAQ » Common problems » comment.php error: can not lock table gl_comments