Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - what does skip-locking in my.cnf do?

Tags:

mysql

I'm using MySQL 5.0.67 on RHEL5 and basing my configuration on my-huge.cnf.

I can't find anything in the MySQL manual for the row 'skip-locking' which appears in the config file.

Should this be replaced with 'skip_external_locking' or should I just remove the row entirely as that is now a default.

MySQL Manual for skip-external-locking

Thanks.

like image 628
Richard Avatar asked Jun 03 '09 08:06

Richard


People also ask

What is skip external locking MySQL?

It's also on default for Linux, as Linux file locking is not yet safe. The only case when you can't use --skip-locking is if you run multiple MySQL servers (not clients) on the same data, or run myisamchk on the table without first flushing and locking the mysqld server tables first.

Does MySQL select lock the table?

MySQL uses table locking (instead of row locking or column locking) on all table types, except InnoDB and BDB tables, to achieve a very high lock speed.

What is read lock in MySQL?

MySQL Locks: Read LocksIf the session holds the READ lock on a table, they cannot perform a write operation on it. It is because the READ lock can only read data from the table. All other sessions that do not acquire a READ lock are not able to write data into the table without releasing the READ lock.

What is lock in share mode MySQL?

LOCK IN SHARE MODE. Sets a shared mode lock on any rows that are read. Other sessions can read the rows, but cannot modify them until your transaction commits.


2 Answers

see http://dev.mysql.com/doc/refman/5.0/en/external-locking.html

quote:

If you run multiple servers that use the same database directory (not recommended), each server must have external locking enabled.

It really just has to do with the dangers presented by multiple processes accessing the same data. In many DBMS situations you want to lock the table/row before performing an operation, and unlocking afterwards. This is to prevent possible data corruption.

Edit: see http://dev.mysql.com/doc/refman/4.1/en/news-4-0-3.html Quote

Renamed --skip-locking to --skip-external-locking.

like image 67
Jonathan Fingland Avatar answered Sep 20 '22 16:09

Jonathan Fingland


An additional note for anyone who doesn't follow the link provided by @Jonathan Fingland :
8.7.4. External Locking

This option only applies to MyISAM tables.

As Richard indicated, external locking is disabled by default. You need to enable external locking if you use myisamchk for write operations or if you use myisampack to pack tables.

From the docs:

If you use myisamchk to perform table maintenance operations on MyISAM tables, you must either ensure that the server is not running, or that the server has external locking enabled so that it locks table files as necessary to coordinate with myisamchk for access to the tables. The same is true for use of myisampack to pack MyISAM tables.

If you use myisamchk for write operations such as repairing or optimizing tables, or if you use myisampack to pack tables, you must always ensure that the mysqld server is not using the table. If you don't stop mysqld, you should at least do a mysqladmin flush-tables before you run myisamchk. Your tables may become corrupted if the server and myisamchk access the tables simultaneously.

like image 23
codewaggle Avatar answered Sep 20 '22 16:09

codewaggle