# MySQL server will not start (Error 2002)



## arc2 (May 18, 2013)

Hi,

I have an issue where I'm not able to start MySQL server 5.5 on FreeBSD 9.1. MySQL is enabled in rc.conf and I get the following error message trying to initialise the MySQL command:


```
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
```

Running `/usr/local/etc/rc.d/mysql-server start` does not throw out any errors but the server still fails to start. The error log under /var/db/mysql looks as follows:


```
130518 14:26:37 mysqld_safe mysqld from pid file /var/db/mysql/tnc.pid ended
130518 15:12:29 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
130518 15:12:29 InnoDB: The InnoDB memory heap is disabled
130518 15:12:29 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130518 15:12:29 InnoDB: Compressed tables use zlib 1.2.7
^G/usr/local/libexec/mysqld: Can't create/write to file '/tmp/ibLDywpJ' (Errcode: 13)
130518 15:12:29  InnoDB: Error: unable to create temporary file; errno: 13
130518 15:12:29 [ERROR] Plugin 'InnoDB' init function returned error.
130518 15:12:29 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130518 15:12:29 [ERROR] Unknown/unsupported storage engine: InnoDB
130518 15:12:29 [ERROR] Aborting

130518 15:12:29 [Note] /usr/local/libexec/mysqld: Shutdown complete
```

I've tried both using and not using a my.cnf file but the it give identical errors. I've set up MySQL numerous times previously under Windows or Ubuntu but I'm quite new to FreeBSD so I appreciate any help, and your patience with a newbie!

Regards,
AC


----------



## ShelLuser (May 18, 2013)

Solely basing myself on this line in the errorlog you pasted above I'd say your problem isn't so much with MySQL but goes much deeper:


```
^G/usr/local/libexec/mysqld: Can't create/write to file '/tmp/ibLDywpJ' (Errcode: 13)
```
If /tmp can't be accessed by common processes then you got yourself a problem, because /tmp is basically the "garbage collector" in Unix (-like) environments. It's _the_ place for programs to store temporary data, so when they can't then there will be a lot of programs which cannot function properly.

So I'd start looking there. Does it exist, does it have the right permissions, can a regular user put something there? (you might want to try `$ touch /tmp/test` to check).

As to setting up MySQL itself, there really isn't that much difference between using it on Linux or Windows and FreeBSD. It's still an issue of providing an optimized my.cnf file where you can define specific parameters and then setting the whole thing up.

The main difference would be that my.cnf will be located under /usr/local/etc by default, instead of the commonly used /etc directory in Linux environments.


----------

