# mysql: unknown variable 'datadir=/var/lib/mysql'

**URL:** https://forums.percona.com/t/mysql-unknown-variable-datadir-var-lib-mysql/2007
**Category:** Other MySQL® Questions
**Created:** [March 4, 2013, 8:57pm UTC](https://forums.percona.com/t/mysql-unknown-variable-datadir-var-lib-mysql/2007 "2013-03-04T20:57:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dungdt](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@dungdt](https://forums.percona.com/u/dungdt)
#### Post date: [March 4, 2013, 8:57pm UTC](https://forums.percona.com/t/mysql-unknown-variable-datadir-var-lib-mysql/2007/1 "2013-03-04T20:57:27Z")

</div>

Hello,

I get a trouble with the configuration file

After I generate my.cnf from tools. percona[.] com

# Generated by Percona Configuration Wizard version REL5-20120208# Configuration name [server8.xipat.com](http://server8.xipat.com) generated for dungdt@xipat.com at 2012-11-20 04:55:11[mysql]# CLIENT #port = 3306socket = /var/lib/mysql/data/mysql.sock[mysqld]# GENERAL #user = mysqldefault\_storage\_engine = InnoDBsocket = /var/lib/mysql/data/mysql.sockpid\_file = /var/lib/mysql/data/mysql.pid# MyISAM #key\_buffer\_size = 32Mmyisam\_recover = FORCE,BACKUP# SAFETY #max\_allowed\_packet = 16Mmax\_connect\_errors = 1000000skip\_name\_resolvesql\_mode = STRICT\_TRANS\_TABLES,ERROR\_FOR\_DIVISION\_BY\_ZERO,NO\_AUTO\_CREATE\_USER,NO\_AUTO\_VALUE\_ON\_ZERO,NO\_ENGINE\_SUBSTITUTION,NO\_ZERO\_DATE,NO\_ZERO\_IN\_DATE,ONLY\_FULL\_GROUP\_BYsysdate\_is\_now = 1innodb = FORCEinnodb\_strict\_mode = 1# DATA STORAGE #datadir = /var/lib/mysql/data/# BINARY LOGGING #log\_bin = /var/lib/mysql/data/mysql-binexpire\_logs\_days = 14sync\_binlog = 1# CACHES AND LIMITS #tmp\_table\_size = 32Mmax\_heap\_table\_size = 32Mquery\_cache\_type = 0query\_cache\_size = 0max\_connections = 500thread\_cache\_size = 50open\_files\_limit = 65535table\_definition\_cache = 4096table\_open\_cache = 1# INNODB #innodb\_flush\_method = O\_DIRECTinnodb\_log\_files\_in\_group = 2innodb\_log\_file\_size = 128Minnodb\_flush\_log\_at\_trx\_commit = 1innodb\_file\_per\_table = 1innodb\_buffer\_pool\_size = 2G# LOGGING #log\_error = /var/lib/mysql/data/mysql-error.loglog\_queries\_not\_using\_indexes = 1slow\_query\_log = 1slow\_query\_log\_file = /var/lib/mysql/data/mysql-slow.log

Then I run command: service mysql stop

I created my.cnf then copy to /etc/my.cnf But after that I couldn’t start Mysql anymore, it said could not find the pid file.

I had to remove [mysqld] and some variables. To get mysql back, here is my my.cnf

[mysql]## Generalport = 3306datadir = /var/lib/mysqltmpdir = /var/lib/mysqltmpsocket = /var/lib/mysql/mysql.sockskip-name-resolve#event-scheduler = 1## Cachethread-cache-size = 50open\_files\_limit = 65535table-open-cache = 10240table-definition-cache = 4096query-cache-size = 0query\_cache\_type = 0## Per-thread Bufferssort-buffer-size = 1Mread-buffer-size = 1Mread-rnd-buffer-size = 1Mjoin-buffer-size = 1Mopen\_files\_limit = 65535## Temp Tablestmp-table-size = 32Mmax-heap-table-size = 32M## Networkingback-log = 100max-connections = 500max-connect-errors = 10000max-allowed-packet = 16Minteractive-timeout = 3600wait-timeout = 600### Storage Enginesdefault-storage-engine = InnoDB## MyISAMkey-buffer-size = 32Mmyisam-sort-buffer-size = 128Mmyisam\_recover = FORCE,BACKUP# SAFETY #max\_allowed\_packet = 16Mmax\_connect\_errors = 1000000skip\_name\_resolvesql\_mode = STRICT\_TRANS\_TABLES,ERROR\_FOR\_DIVISION\_BY\_ZERO,NO\_AUTO\_CREATE\_USER,NO\_AUTO\_VALUE\_ON\_ZERO,NO\_ENGINE\_SUBSTITUTION,NO\_ZERO\_DATE,NO\_ZERO\_IN\_DATE,ONLY\_FULL\_GROUP\_BYsysdate\_is\_now = 1innodb = FORCEinnodb\_strict\_mode = 1# BINARY LOGGING #log\_bin = /var/lib/mysql/data/mysql-binexpire\_logs\_days = 7sync\_binlog = 1## InnoDBinnodb-buffer-pool-size = 2Ginnodb-log-file-size = 128Minnodb-log-buffer-size = 4Minnodb-file-per-table = 1innodb\_log\_files\_in\_group = 2innodb\_flush\_log\_at\_trx\_commit = 1innodb\_thread\_concurrency=8innodb\_flush\_method=O\_DIRECT# LOGGING #log\_error = /var/lib/mysql/data/mysql-error.loglog\_queries\_not\_using\_indexes = 1slow\_query\_log = 1slow\_query\_log\_file = /var/lib/mysql/data/mysql-slow.log

The server could start again. But I get another trouble, when I run command: mysql, it returned an error:

mysql: unknown variable ‘datadir=/var/lib/mysql’

Could you kindly advise how to solve this issue please. Thank you very much.

---

<div class="post-metadata">

### Author: ![niljoshi](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/niljoshi/32/16889_2.png) [@niljoshi](https://forums.percona.com/u/niljoshi)
#### Post date: [March 5, 2013, 10:04pm UTC](https://forums.percona.com/t/mysql-unknown-variable-datadir-var-lib-mysql/2007/2 "2013-03-05T22:04:14Z")

</div>

Hi,

AFAIK, In my.cnf file, [mysql] is for MySQL client and [mysqld] is for MySQL server. So I would suggest you should add all server related parameters under [mysqld] in my.cnf and try to start mysql. If you are getting any error please update here. Thanks.

---

<div class="post-metadata">

### Author: ![dungdt](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@dungdt](https://forums.percona.com/u/dungdt)
#### Post date: [March 6, 2013, 2:09am UTC](https://forums.percona.com/t/mysql-unknown-variable-datadir-var-lib-mysql/2007/3 "2013-03-06T02:09:26Z")

</div>

Hello,

Thank you for your responding, Once I update my.cnf as suggestion from tools . percona with content below

[mysql]# CLIENT #port = 3306socket = /var/lib/mysql/data/mysql.sock[mysqld]# GENERAL #user = mysqldefault\_storage\_engine = InnoDBsocket = /var/lib/mysql/data/mysql.sockpid\_file = /var/lib/mysql/data/mysql.pid# MyISAM #key\_buffer\_size = 32Mmyisam\_recover = FORCE,BACKUP# SAFETY #max\_allowed\_packet = 16Mmax\_connect\_errors = 1000000skip\_name\_resolvesql\_mode = STRICT\_TRANS\_TABLES,ERROR\_FOR\_DIVISION\_BY\_ZERO,NO\_AUTO\_CREATE\_USER,NO\_AUTO\_VALUE\_ON\_ZERO,NO\_ENGINE\_SUBSTITUTION,NO\_ZERO\_DATE,NO\_ZERO\_IN\_DATE,ONLY\_FULL\_GROUP\_BYsysdate\_is\_now = 1innodb = FORCEinnodb\_strict\_mode = 1# DATA STORAGE #datadir = /var/lib/mysql/data/# BINARY LOGGING #log\_bin = /var/lib/mysql/data/mysql-binexpire\_logs\_days = 14sync\_binlog = 1# CACHES AND LIMITS #tmp\_table\_size = 32Mmax\_heap\_table\_size = 32Mquery\_cache\_type = 0query\_cache\_size = 0max\_connections = 500thread\_cache\_size = 50open\_files\_limit = 65535table\_definition\_cache = 4096table\_open\_cache = 1# INNODB #innodb\_flush\_method = O\_DIRECTinnodb\_log\_files\_in\_group = 2innodb\_log\_file\_size = 128Minnodb\_flush\_log\_at\_trx\_commit = 1innodb\_file\_per\_table = 1innodb\_buffer\_pool\_size = 2G# LOGGING #log\_error = /var/lib/mysql/data/mysql-error.loglog\_queries\_not\_using\_indexes = 1slow\_query\_log = 1slow\_query\_log\_file = /var/lib/mysql/data/mysql-slow.log

I get the this error

Starting MySQL (Percona Server)… ERROR! The server quit without updating PID file (/var/lib/mysql/data//[MY\_SERVER\_NAME].pid).

Could you advise please?

Thank you very much/

---

<div class="post-metadata">

### Author: ![hellogxp](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@hellogxp](https://forums.percona.com/u/hellogxp)
#### Post date: [August 11, 2013, 9:15am UTC](https://forums.percona.com/t/mysql-unknown-variable-datadir-var-lib-mysql/2007/4 "2013-08-11T09:15:57Z")

</div>

[QUOTE=niljoshi;7752]  
Hi,

AFAIK, In my.cnf file, [mysql] is for MySQL client and [mysqld] is for MySQL server. So I would suggest you should add all server related parameters under [mysqld] in my.cnf and try to start mysql. If you are getting any error please update here. Thanks.  
[/QUOTE]

hey i have meet the same problem,and i install percona5.6.10 via compile(i download Percona-Server-5.6.10-alpha60.2.tar.gz),when i finished install, all is well,but after a short time when i use /etc/init.d/mysqld restart i get error like "The server quit without updating PID file ",and how can i fix it,below is /etc/my.cnf  
[mysqld]

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb\_buffer\_pool\_size = 128M

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log\_bin

# These are commonly set, remove the # and set as required.

basedir = /usr/local/mysql  
datadir = /var/mysql/data  
port = 3306  
server\_id = 1  
socket = /tmp/mysql.sock  
sort\_buffer\_size = 1M  
join\_buffer\_size = 1M  
query\_cache\_size = 50M  
query\_cache\_limit = 2M  
query\_cache\_min\_res\_unit = 2k  
thread\_stack = 192K  
tmp\_table\_size = 246M  
max\_heap\_table\_size = 50M  
key\_buffer\_size = 256M  
read\_buffer\_size = 1M  
read\_rnd\_buffer\_size = 10M  
bulk\_insert\_buffer\_size = 10M  
slow\_query\_log = 1  
log-error = /var/mysql/mysql\_error.log  
slow\_query\_log\_file = /var/mysq/query\_slow.log  
long\_query\_time = 2  
log-queries-not-using-indexes = ON

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join\_buffer\_size = 128M

# sort\_buffer\_size = 2M

# read\_rnd\_buffer\_size = 2M

sql\_mode=NO\_ENGINE\_SUBSTITUTION,STRICT\_TRANS\_TABLES

---

<div class="post-metadata">

### Author: ![mirfan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mirfan/32/16890_2.png) [@mirfan](https://forums.percona.com/u/mirfan)
#### Post date: [August 12, 2013, 1:11am UTC](https://forums.percona.com/t/mysql-unknown-variable-datadir-var-lib-mysql/2007/5 "2013-08-12T01:11:59Z")

</div>

Hi,

Can you please show us last 20 lines of error log to identify the issue.
