# Mysql installs just don't seem to work



## risingfish (Jan 24, 2015)

I'm fairly new to FreeBSD, but have had a good success rate to far. I've been able to get Samba up and running, Plex, Webmin, Apache 2.4, and even a Minecraft server. MySQL is being elusive, however. I've tried installing Mysql 5.5 and 5.6 using pkg, neither of which produced a working server. I've now been trying to use ports. MySQL 5.6 builds and seems to install, but the server will not run. Anyone have any pages they could suggest for a step by step install and run?

Here's the extent of the output, the log doesn;t show anything different.

```
[root@homestor /usr/local]# ./bin/mysqld_safe start
150123 15:38:07 mysqld_safe Logging to '/usr/local/data/mysql//homestor.err'.
150123 15:38:07 mysqld_safe Starting mysqld daemon with databases from /usr/local/data/mysql/
150123 15:38:08 mysqld_safe mysqld from pid file /usr/local/data/mysql//homestor.pid ended
```
Any help would be greatly appreciated!

[quick edit]
I've been using Linux as a development desktop environment for many years, so I am familiar with *nix environments.


----------



## talsamon (Jan 24, 2015)

There are  several ways to start `mysql`.

In /etc/rc.conf:

```
mysql_enable="YES"
mysql_optfile="/etc/my.cnf"
mysql_dbdir="/var/db/mysql"
```
and
`/usr/local/etc/rc.d/mysql-server start`
or
`mysqladmin -h `hostname` --port=3306`
or
`mysqld_safe --skip-grant-tables`

Check owner and permissions:
`mkdir  /var/lib/mysql/ (if not already there)
chown -R username:mysql /var/lib/mysql/
chown -R username:mysql /var/lib/db
chown mysql:wheel /tmp/mysql.sock
chmod 777 /tmp/mysql.sock`
Add the user to the group mysql.

Maybe it's necessary to do:
`mysql_install_db`


----------



## usdmatt (Jan 24, 2015)

I install MySQL regularly from packages and ports and have never had a problem. It does default to /var/db/mysql for the data path so looks like you may have messed with the default configuration after installing?

Don't use the MySQL binaries directly to run it. On first run the core databases need to be initialised which may be the problem. This is all handled for you if you use the rc system. Add it to rc.conf then just use service() to start it


```
echo 'mysql_enable="YES"' >> /etc/rc.conf
service mysql-server start
```
I've never had that fail after a new, unmodified install. Purely adding the mysql5x-server package, followed by the two commands above should be enough to get a working server that starts on boot.

If it doesn't start, look for a error in the log file in the data directory.


----------



## risingfish (Jan 25, 2015)

Thanks guys. I'll give it a shot today and post the results.


----------



## risingfish (Jan 25, 2015)

Ok, I was going to do it this evening but couldn't wait. usdmatt, your response gave me the key to the puzzle. I couldn't track down where mysql was logging originally so was running in the dark. After you mentioned that the default install uses /var/db/mysq, I finally had a log I could `tail`. Of course immediately this  pops up when I try to run it after using the `pkg install` method:

```
2015-01-25 05:56:40 63075 [Note] InnoDB: Not using CPU crc32 instructions
/usr/local/libexec/mysqld: Can't create/write to file '/tmp/ib92zTov' (Errcode: 13 - Permission denied)
2015-01-25 05:56:40 802c06400  InnoDB: Error: unable to create temporary file; errno: 13
2015-01-25 05:56:40 63075 [ERROR] Plugin 'InnoDB' init function returned error.
2015-01-25 05:56:40 63075 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-01-25 05:56:40 63075 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-01-25 05:56:40 63075 [ERROR] Aborting
```

So I went and looked at the /tmp dir and lo and behold it was owned by plex:plex with a 755 permission (I think that's the rwxr-xr-x right? I can never remember). A quick `chown` and `chmod` and mysql starts right up of course.

Thank you both of you for taking the time to respond to my cry for help!


----------

