# Mysql Hardware Raid error



## denniskai1234 (Mar 6, 2014)

Hello.

I installed MySQL 5.6 on my FreeBSD 9.2 amd64 server. When I open it on ssh this appears:

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

I read something about add raid option to the install, because the server got a hardware raid (2x120gb ssd)

Sorry for my bad english, still learning it


----------



## SirDice (Mar 6, 2014)

RAID has nothing to do with this. Your MySQL is probably not running and the error is the result of that.


----------



## denniskai1234 (Mar 6, 2014)

```
root@ns317604:~ # /usr/local/etc/rc.d/mysql-server start
Starting mysql.
su: unknown login: mysql
/usr/local/etc/rc.d/mysql-server: WARNING: failed to start mysql
```


----------



## SirDice (Mar 6, 2014)

Ah, you seem to be missing the @mysql user. I've had that happen a couple of times. This should add the proper user account:

```
pw groupadd mysql -g 88
pw useradd mysql -u 88 -g 88 -d /var/db/mysql -s /usr/sbin/nologin -c "MySQL Daemon"
```
After that MySQL should start.


----------



## denniskai1234 (Mar 6, 2014)

pw: group name `mysql' already exists

On both commands.


----------



## SirDice (Mar 6, 2014)

Hmm.. Then it appears your password database is out of sync with /etc/passwd. Simplest solution, `vipw` and without making any changes, save and quit.


----------



## denniskai1234 (Mar 6, 2014)

Error still appears.


----------



## SirDice (Mar 6, 2014)

What do these return? 

`getent passwd mysql`
`getent group mysql`


----------



## denniskai1234 (Mar 6, 2014)

```
root@ns317604:~ # getent passwd mysql
root@ns317604:~ # getent group mysql
mysql:*:88
```


----------



## SirDice (Mar 6, 2014)

Ok, the group seems to exist, just not the user account. 
`pw useradd mysql -u 88 -g 88 -d /var/db/mysql -s /usr/sbin/nologin -c "MySQL Daemon"`


----------



## denniskai1234 (Mar 6, 2014)

Already tried this:

```
root@ns317604:~ # pw useradd mysql -u 88 -g 88 -d /var/db/mysql -s /usr/sbin/nologin -c "MySQL Daemon"
pw: user 'mysql' already exists
```


----------



## SirDice (Mar 6, 2014)

Try this: `pwd_mkdb /etc/master.passwd` then see if the user exists. For some reason your database is out of sync with the passwd files.


----------



## denniskai1234 (Mar 6, 2014)

```
root@ns317604:~ # pwd_mkdb /etc/master.passwd
root@ns317604:~ #
```

It's a fresh installed FreeBSD. I just run `portsnap fetch extract` and then I installed MySQL:

```
cd /usr/ports/databases/mysql56-server
make install WITH_XCHARSET=all clean
echo 'mysql_enable="YES"' >> /etc/rc.conf
```


----------



## SirDice (Mar 6, 2014)

denniskai1234 said:
			
		

> ```
> root@ns317604:~ # pwd_mkdb /etc/master.passwd
> root@ns317604:~ #
> ```


Good. Now check if the @mysql user exists: `getent passwd mysql`. If it does MySQL should start without problems: `service mysql-server start`.


----------



## denniskai1234 (Mar 6, 2014)

I reinstalled FreeBSD now.

Before the installation I run `pwd_mkdb /etc/master.passwd` and now it works.

Thanks man  :beer


----------



## SirDice (Mar 6, 2014)

denniskai1234 said:
			
		

> I reinstalled FreeBSD now.


A bit overkill but alas. 



> Before the installation I run `pwd_mkdb /etc/master.passwd` and now it works.


That's not needed at that point. Normally the @mysql gets automatically created during the installation of MySQL. This sometimes doesn't work and the passwd files and databases go out of sync.  The command was to try and get everything back in sync.


----------

