# MySQL.sock permissions



## manti (Nov 30, 2010)

1. Install


`#portsnam fetch extract update...`
`#cd /usr/ports/database/mysql**-server/` <-- I checked the all 
versions.
`#make install clean....`


2. Running.

`#cd /usr/local/etc/rc.d/`
`#./mysql-server.sh`

```
Starting mysql.
```
`#./mysql-server.sh stop`

```
mysql not running? (check /var/db/mysql//domena.pid).
```
[/CODE]

3. Permissions
Kod:

`# ls -ld /var/db/mysql`

```
drwxrwxrwx  5 mysql  mysql  512 Nov 30 18:29 /var/db/mysql
```
`#ls -ld /var/tmp`

```
drwxr-xr-t  3 root  wheel  1024 Nov 30 18:25 /var/tmp
```
`#ls -ld /tmp`

```
drwxr-xr-t  9 root  wheel  1024 Nov 30 18:25 /tmp
```


4. Other

`mysql_install_db` (run root.)

```
Installing MySQL system tables...
OK
Filling help tables...
OK
```


`# mysql_install_db --user=mysql --datadir=/var/db/mysql`

```
Installing MySQL system tables...
ERROR: 1004  Can't create file '/var/tmp/#sql786_1_0.frm' (errno: 13)
101130 19:31:50 [ERROR] Aborting

101130 19:31:50 [Note] /usr/local/libexec/mysqld: Shutdown complete

Installation of system tables failed!

Examine the logs in /var/db/mysql for more information.
```




```
#mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck'...
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through 
socket '/tmp/mysql.sock' (2) when trying to connect
FATAL ERROR: Upgrade failed
```


```
#mysqld_safe
Starting mysqld daemon with databases from /var/db/mysql
STOPPING server from pid file /var/db/mysql/domena.pid
101130 18:48:13  mysqld ended
```


```
#cd /var/db/mysql
pic domena.pl.err
mysqld started
/usr/local/libexec/mysqld: Can't create/write to file '/var/tmp/ibb83jeL' (Errcode: 13)
101130 18:48:12  InnoDB: Error: unable to create temporary file; errno: 13
101130 18:48:12 [ERROR] bdb:  /var/db/mysql: Permission denied
101130 18:48:12 [ERROR] bdb:  /var/db/mysql/log.0000000001: Permission denied
101130 18:48:12 [ERROR] bdb:  PANIC: Permission denied
101130 18:48:12 [ERROR] bdb:  PANIC: DB_RUNRECOVERY: Fatal error, run database recovery
101130 18:48:12 [ERROR] bdb:  fatal region error detected; run recovery
101130 18:48:12 [ERROR] bdb:  /var/db/mysql: Permission denied
101130 18:48:13 [ERROR] Can't start server : Bind on unix socket: Permission denied
101130 18:48:13 [ERROR] Do you already have another mysqld server
 running on socket: /tmp/mysql.sock ?
101130 18:48:13 [ERROR] Aborting

101130 18:48:13 [Note] /usr/local/libexec/mysqld: Shutdown complete

101130 18:48:13  mysqld ended
```


```
# ls -ld /var/db/mysql
drwx------  4 mysql  88  512 Nov 30 20:49 /var/db/mysql
```


Please help...


----------



## manti (Nov 30, 2010)

```
find /var/db/mysql -type d | xargs chmod 700
find /var/db/mysql -type f | xargs chmod 660
```
It doesn't work..


----------



## graudeejs (Nov 30, 2010)

```
# chown -R mysql:mysql /var/db/mysql
# chmod u+rwx,go= /var/db/mysql
```
and try to start again


----------



## manti (Dec 1, 2010)

> # chown -R mysql:mysql /var/db/mysql
> # chmod u+rwx,go= /var/db/mysql




```
# mysql_install_db --user=mysql
Installing MySQL system tables...
ERROR: 1  Can't create/write to file '/var/db/mysql/mysql/db.MYI' (Errcode: 13)
101201  8:46:43 [ERROR] Aborting

101201  8:46:43 [Note] /usr/local/libexec/mysqld: Shutdown complete
```


Installation of system tables failed!  Examine the logs in
/var/db/mysql for more information.




```
#cd /var/db/mysql <- for more information.
# ls
mysql   test
# cd mysql/
# ls
# cd ..
# cd test/
# ls
```

???


----------



## SirDice (Dec 1, 2010)

Is MySQL actually running? You need a running MySQL before you can do mysql_install_db. If I recall correctly you don't even need to do that. It'll be done automatically when MySQL starts for the first time.


----------



## manti (Dec 1, 2010)

```
# ls -ld /var/db/mysql
drwx------  4 mysql  wheel  512 Dec  1 08:46 /var/db/mysql
```



```
#mysqld_safe
101201 08:58:37 mysqld_safe Logging to '/var/db/mysql/hq.hostname.err'.
101201 08:58:37 mysqld_safe Starting mysqld daemon with databases from 
/var/db/mysql
101201 08:58:38 mysqld_safe mysqld from pid file /var/db/mysql/hq.hostname.pid
 ended
[root@hq /usr/local/etc/rc.d]# pic /var/db/mysql/hq.hostname.err
.lf 1 /var/db/mysql/hq.hostname.err
101201 08:58:37 mysqld_safe Starting mysqld daemon with databases from 
/var/db/mysql
101201  8:58:37 [Note] [color="red"]Plugin 'FEDERATED' is disabled.
/usr/local/libexec/mysqld: Table 'mysql.plugin' doesn't exist
101201  8:58:37 [ERROR] Can't open the mysql.plugin table. Please run 
mysql_upgrade to create it.[/color]
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3
/usr/local/libexec/mysqld: [color="Red"]Can't create/write to file 
'/var/tmp/ibLyEDUG'[/color] (Errcode: 13)
101201  8:58:38  InnoDB: Error: unable to create temporary file; errno: 9
101201  8:58:38 [ERROR] Plugin 'InnoDB' init function returned error.
101201  8:58:38 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE 
failed.
101201  8:58:38 [ERROR] Unknown/unsupported storage engine: InnoDB
101201  8:58:38 [ERROR] Aborting

101201  8:58:38 [Note] /usr/local/libexec/mysqld: Shutdown complete

101201 08:58:38 mysqld_safe mysqld from pid file /var/db/mysql/hq.hostname.pid
 ended
```


```
# ls -ld /var/tmp/
drwxr-xr-t  4 root  wheel  1024 Dec  1 08:56 /var/tmp/
ls -la /var/tmp/
total 8
drwxr-xr-t   4 root   wheel  1024 Dec  1 08:56 .
drwxr-x---  31 root   wheel  1024 Nov 26 11:07 ..
drwxr-xr-t   3 mysql  wheel   512 Nov 30 05:49 temproot
drwxr-xr-t   2 mysql  wheel   512 Nov 30 18:54 vi.recover
```


```
# mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck with default connection arguments
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through 
socket '/tmp/mysql.sock' (2) when trying to connect
FATAL ERROR: Upgrade failed
```


```
# ls -la /tmp
total 386
drwxr-xr-t  10 root   wheel    1024 Dec  1 05:30 .
drwxr-xr-x  26 root   wheel    1024 Nov 24 02:08 ..
drwx------   2 root   wheel     512 Nov 25 09:46 .ICE-unix
drwx------   2 root   wheel     512 Nov 25 09:46 .X11-unix
drwx------   2 root   wheel     512 Nov 25 09:46 .XIM-unix
drwx------   2 root   wheel     512 Nov 25 09:46 .font-unix
-rwxr-xr-t   1 root   wheel    1433 Nov 26 00:09 3strikes.db
-rwxr-xr-t   1 root   wheel      53 Nov 26 00:09 commandLine.db
-rwxr-xr-t   1 root   wheel      37 Nov 26 00:09 configure.db
--cat---
```


```
ls -ld /tmp/
drwxr-xr-t  10 root  wheel  1024 Dec  1 05:30 /tmp/
```


----------



## manti (Dec 1, 2010)

SirDice said:
			
		

> Is MySQL actually running? You need a running MySQL before you can do mysql_install_db. If I recall correctly you don't even need to do that. It'll be done automatically when MySQL starts for the first time.



`# ps axww | grep mysql`

Nothing any processes... I can not run MySQL...


----------



## SirDice (Dec 1, 2010)

Start it the regular way:
`# /usr/local/etc/rc.d/mysql-server start`


----------



## manti (Dec 1, 2010)

SirDice said:
			
		

> Start it the regular way:
> `# /usr/local/etc/rc.d/mysql-server start`




```
# ./mysql-server start
Starting mysql.
# ./mysql-server status
mysql is not running.
```


rc.conf add 
	
	



```
enable_mysql="YES"
```
and: `/usr/local/etc/rc.d/mysql-server`


```
: ${mysql_enable="YES"}
: ${mysql_limits="NO"}
: ${mysql_dbdir="/var/db/mysql"}
: ${mysql_args=""}
```


----------



## SirDice (Dec 1, 2010)

Ok. Now check /var/log/messages and/or /var/db/mysql/`hostname`.err.


----------



## manti (Dec 1, 2010)

SirDice said:
			
		

> Ok. Now check /var/log/messages and/or /var/db/mysql/`hostname`.err.




```
#[FILE]tail -f /var/log/messages[/FILE]
Dec  1 08:28:40 hq inetd[1624]: ftp/tcp: bind: Address already in use
Dec  1 08:38:39 hq inetd[1624]: ftp/tcp: bind: Address already in use
Dec  1 08:43:55 hq syslogd: Logging subprocess 31390 (exec    
          /usr/local/sbin/sshit) exited with status 2.
Dec  1 08:44:02 hq syslogd: Logging subprocess 31396 (exec    
          /usr/local/sbin/sshit) exited with status 2.
Dec  1 08:44:06 hq su: manti to root on /dev/pts/0
Dec  1 08:44:06 hq syslogd: Logging subprocess 31401 (exec    
          /usr/local/sbin/sshit) exited with status 2.
Dec  1 08:48:39 hq inetd[1624]: ftp/tcp: bind: Address already in use
Dec  1 08:58:39 hq inetd[1624]: ftp/tcp: bind: Address already in use
Dec  1 09:08:39 hq inetd[1624]: ftp/tcp: bind: Address already in use
Dec  1 09:18:39 hq inetd[1624]: ftp/tcp: bind: Address already in use
```
I changed the configuration of inetd.conf...


```
# cd /var/db/mysql/
# [FILE]pic hq.hostname.err[/FILE]
.lf 1 hq.hostname.err
101201 08:58:37 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
101201  8:58:37 [Note] [color="Red"]Plugin 'FEDERATED' is disabled.[/color]
/usr/local/libexec/mysqld: Table 'mysql.plugin' doesn't exist
101201  8:58:37 [ERROR] Can't open the mysql.plugin table. Please run 
mysql_upgrade to create it.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3
/usr/local/libexec/mysqld: [color="red"]Can't create/write to file 
'/var/tmp/ibLyEDUG' (Errcode: 13)[/color]
101201  8:58:38  InnoDB: Error: unable to create temporary file; errno: 9
101201  8:58:38 [ERROR] Plugin 'InnoDB' init function returned error.
101201  8:58:38 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
101201  8:58:38 [ERROR] Unknown/unsupported storage engine: InnoDB
101201  8:58:38 [ERROR] Aborting

101201  8:58:38 [Note] /usr/local/libexec/mysqld: Shutdown complete

101201 08:58:38 mysqld_safe mysqld from pid file /var/db/mysql/hq.hostname.pid
 ended
```


----------



## SirDice (Dec 1, 2010)

What are the permissions on /var/tmp/?


----------



## manti (Dec 1, 2010)

SirDice said:
			
		

> What are the permissions on /var/tmp/?




```
#[CMD=" "]ls -ld /var/tmp[/CMD]
drwx-----T  4 root  wheel  1024 Dec  1 09:45 /var/tmp
```


```
#[CMD=" "]ls -la /var/tmp/[/CMD]
total 8
drwx-----T   4 root   wheel  1024 Dec  1 09:45 .
drwxr-x---  31 root   wheel  1024 Nov 26 11:07 ..
drwxr-xr-t   3 mysql  wheel   512 Nov 30 05:49 temproot
drwxr-xr-t   2 mysql  wheel   512 Nov 30 18:54 vi.recover
```


----------



## SirDice (Dec 1, 2010)

manti said:
			
		

> ```
> #ls -ld /var/tmp
> drwx-----T  4 root  wheel  1024 Dec  1 09:45 /var/tmp
> ```


Those are not correct and it's probably the cause why MySQL refuses to start. They should be 1777:

```
root@molly:~#ls -ld /var/tmp/
drwxrwxrwt  3 root  wheel  512 Nov 25 23:03 /var/tmp/
```


----------



## DutchDaemon (Dec 1, 2010)

manti, please format your posts!


----------



## manti (Dec 1, 2010)

SirDice said:
			
		

> Those are not correct and it's probably the cause why MySQL refuses to start. They should be 1777:
> 
> ```
> root@molly:~#ls -ld /var/tmp/
> ...



Reinstall MySQL55...


`[root@hq /usr/local/etc/rc.d]# chmod 1777 /var/tmp`
`[root@hq /usr/local/etc/rc.d]# ls -ld /var/tmp`

```
drwxrwxrwt  4 root  wheel  1024 Dec  1 18:15 /var/tmp[/CMD]
```
`[root@hq /usr/local/etc/rc.d]# ./mysql-server start`

```
Starting mysql.
```
`[root@hq /usr/local/etc/rc.d]# ./mysql-server status`

```
mysql is not running.
```
`[root@hq /usr/local/etc/rc.d]# ps axww | grep mysql`

```
13252   0  S+     0:00.02 grep mysql
34962   0  TW     0:00.00 /bin/sh -ec for file in mysql-5.5.7-rc.tar.gz; do 
 if ! (cd /usr/ports/databases/mysql55-server/work && /usr/bin/gzip -nf -9 -dc 
/usr/ports/distfiles//$file | /usr/bin/tar -xf - --no-same-owner --no-same-
permissions); then  exit 1;  fi;  done
34963   0  TW     0:00.00 /bin/sh -ec for file in mysql-5.5.7-rc.tar.gz; do  
if ! (cd /usr/ports/databases/mysql55-server/work && /usr/bin/gzip -nf -9 -dc 
/usr/ports/distfiles//$file | /usr/bin/tar -xf - --no-same-owner --no-same-
permissions); then  exit 1;  fi;  done
34964   0  TW     0:00.00 /usr/bin/gzip -nf -9 -dc 
/usr/ports/distfiles//mysql-5.5.7-rc.tar.gz
[root@hq /usr/local/etc/rc.d]#
```


----------



## SirDice (Dec 2, 2010)

manti said:
			
		

> Reinstall MySQL55...


Why?!?


----------



## manti (Dec 2, 2010)

SirDice said:
			
		

> Why?!?



Because in another forum that suggested...


----------



## manti (Dec 3, 2010)

`# pic /var/db/mysql/hq.hostname.err`

```
/usr/local/libexec/mysqld: Can't create/write to file '/var/tmp/ibdIYhrC' (Errcode: 13)
```
This command fixed the run mysql.

`# chmod 1777 /var`

`ps axww | grep mysql`


```
51192   3  T      0:00.11 /bin/sh /usr/local/bin/mysqld_safe --user=mysql -
-log
51265   3  T      0:01.21 /usr/local/libexec/mysqld --basedir=/usr/local --
datadir=/var/db/mysql --plugin-dir=/usr/local/lib/mysql/plugin --user=mysql --log 
--log-error=/var/db/mysql/hq.hostname.err --pid-
file=/var/db/mysql/hq.hostname.pid
51343   3  R+     0:00.01 grep mysql
```

Thanks for help!


----------



## SirDice (Dec 3, 2010)

manti said:
			
		

> This command fixed the run mysql.
> 
> `# chmod 1777 /var`


Revert that asap. The correct permissions on /var/ are 755.


----------



## DutchDaemon (Dec 3, 2010)

Ergo: [cmd=]chmod -R 1777 /var/tmp[/cmd]


----------



## manti (Dec 3, 2010)

SirDice said:
			
		

> Revert that asap. The correct permissions on /var/ are 755.




Ok, thans SirDice. I can still run MySQL...

`#./mysql-server stop`

```
Stopping mysql.
```
`#chmod 1755 /var`
`#./mysql-server start`

```
Starting mysql.
```
`# ps axww |grep my`

```
46461  ??  Ss     0:00.11 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-
file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-
file=/var/db/mysql/hq.hostname.pid
46541  ??  S      0:01.11 /usr/local/libexec/mysqld --defaults-extra-
file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --plugin-
dir=/usr/local/lib/mysql/plugin --log-error=/var/db/mysql/hq.hostname.err --pid-
file=/var/db/mysql/hq.hostname.pid
```


----------



## DutchDaemon (Dec 3, 2010)

Sigh:

[cmd=]chmod 755 /var[/cmd]
[cmd=]chmod -R 1777 /var/tmp[/cmd]


----------



## manti (Dec 3, 2010)

DutchDaemon said:
			
		

> Sigh:
> 
> [cmd=]chmod 755 /var[/cmd]
> [cmd=]chmod -R 1777 /var/tmp[/cmd]



`# chmod -R 1777 /var/tmp`

```
chmod: /var/tmp/temproot/var/empty: Operation not permitted
```

But I can still run MySQL.


----------



## DutchDaemon (Dec 4, 2010)

Just to make sure:

[cmd=]ls -ld /var[/cmd] should give 
	
	



```
drwxr-xr-x
```
[cmd=]ls -ld /var/tmp[/cmd] should give 
	
	



```
drwxrwxrwt
```


----------



## manti (Dec 4, 2010)

DutchDaemon said:
			
		

> Just to make sure:
> 
> [cmd=]ls -ld /var[/cmd] should give
> 
> ...



`hq# ls -ld /var`

```
drwxr-xr-t  31 root  wheel  1024 Dec  1 22:21 /var
```
`hq# ls -ld /var/tmp/`

```
drwxrwxrwt  4 mysql  mysql  1024 Dec  3 22:22 /var/tmp/
```

It is all good, mysql running.
Thank you very much.


----------



## DutchDaemon (Dec 4, 2010)

No, it's not all good. Just read what you post. There should not be a sticky bit (*t*) on the /var/ directory. Run:

[cmd=]chmod 0755 /var[/cmd].

Moreover: /var/tmp/ should *not* be owned by user/group *mysql*.

[cmd=]chown root:wheel /var/tmp[/cmd]


----------



## manti (Dec 4, 2010)

DutchDaemon said:
			
		

> No, it's not all good. Just read what you post. There should not be a sticky bit (*t*) on the /var/ directory. Run:
> 
> [cmd=]chmod 0755 /var[/cmd].
> 
> ...



Ok, thanks! ;-)


[cmd=]hq# chmod 0755 /var[/cmd]
[cmd=]hq# chown root:wheel /var/tmp[/cmd]
[cmd=]hq# ./mysql-server stop[/cmd]

```
Stopping mysql.
Waiting for PIDS: 46541.
```
[cmd=]hq# ./mysql-server start[/cmd]

```
Starting mysql.
```
[cmd=]hq# ps axww | grep mysql[/cmd]

```
46609  ??  Ss     0:00.11 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-
file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-
file=/var/db/mysql/hq.hostname.pid
46753  ??  SL     0:00.93 /usr/local/libexec/mysqld --defaults-extra-
file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --plugin-
dir=/usr/local/lib/mysql/plugin --log-error=/var/db/mysql/hq.hostname.err --pid-
file=/var/db/mysql/hq.hostname.pid
```


----------

