Have problems to start MySQL 5.7

I used pkg(8) to install MySQL 5.7 by this command:

$ sudo pkg install mysql57-server

Then I have problems to start MySQL, and the command and output is listed below:
Code:
$ sudo sysrc mysql_enable=yes
mysql_enable:  -> yes

$ sudo service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
And I search by google and someone said the /usr/local/etc/rc.d/mysql-server file have to be modified. The line
Code:
eval $mysql_install_db $mysql_install_db_args >/dev/null 2>/dev/null
should comment the string
Code:
">/dev/null 2>/dev/null"
.

I follow this order, and finally get these errors:
Code:
$ sudo service mysql-server start
2016-06-15 22:55:14 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-06-15 22:55:14 [ERROR]   Child process: /usr/local/libexec/mysqldterminated prematurely with errno= 32
2016-06-15 22:55:14 [ERROR]   Failed to execute /usr/local/libexec/mysqld --defaults-extra-file=/usr/local/etc/mysql/my.cnf --bootstrap --datadir=/var/db/mysql --lc-messages-dir=/usr/local/share/mysql --lc-messages=en_US --basedir=/usr/local
-- server log begin --
mysqld:
-- server log end --
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
Please help me ,thanks!
 
You never have to edit any of the rc(8) files.

Assuming this is a new install:
Code:
service mysql-server stop # make sure it's not running
rm -rf /var/db/mysql/*
chown mysql:mysql /var/db/mysql # In case the permissions are wrong
service mysql-server start
 
You never have to edit any of the rc(8) files.

Assuming this is a new install:
Code:
service mysql-server stop # make sure it's not running
rm -rf /var/db/mysql/*
chown mysql:mysql /var/db/mysql # In case the permissions are wrong
service mysql-server start

I follow your instructions, but this error still comes out:
Code:
% sudo service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
 
So I was not along. If this is in a jail see this:
https://forums.freebsd.org/threads/56564/

And if not, that would mean that we both have a dependency problem. I now believe it is the order in which to include each dependency, and believe me, it was a chore downloading each pkg as I needed them. This way I did not miss anything. Order was important in at least two places that I saw with my own eyes but forgot where.

If it works for you, that will answer all our questions.
 
There's a similar problem solved on SO at this link.
Solution paraphrased here in case the link dies:

<snip>
Check that you've created a MySQL root user.
Not all installation scripts create them automatically.

To create a root user, run:
mysqld --initialize --user=mysql [with random root password]
</snip>
 
You never have to edit any of the rc(8) files.

Assuming this is a new install:
Code:
service mysql-server stop # make sure it's not running
rm -rf /var/db/mysql/*
chown mysql:mysql /var/db/mysql # In case the permissions are wrong
service mysql-server start

Thank you so much! This has solved the problem I've been facing for 2hrs.
 
I came here with the same problem. It was the first search result. It didn't help.

I went to the second search result. That helped.

From my own blog post earlier this year:

This loses your configuration and your data.

Code:
sudo pkg delete mysql57-server
sudo rm -rf /usr/local/etc/mysql
sudo rm -rf /var/db/mysql
sudo pkg install mysql57-server
sudo service mysql-server start
 
If you have an existing install you need to be aware the socket has changed location recently (from /tmp/mysql.socket to /var/run/mysql.socket). Also the standard location for my.cnf changed some time ago, this used to be /var/db/mysql/my.cnf but is now /usr/local/etc/mysql/my.cnf.
 
Back
Top