Solved Cannot start mysql

find /var/db/mysql/ \! -user mysql

try that as root
should find nothing

Code:
$ su
Password:
root@ellamay:/usr/home/steve # find /var/db/mysql/\! -user mysql
find: /var/db/mysql/!: No such file or directory
root@ellamay:/usr/home/steve # find /var/db/mysql/ \! -user mysql
root@ellamay:/usr/home/steve #
 
$ su Password: root@ellamay:/usr/home/steve # find /var/db/mysql/\! -user mysql find: /var/db/mysql/!: No such file or directory root@ellamay:/usr/home/steve # find /var/db/mysql/ \! -user mysql root@ellamay:/usr/home/steve #
leave a space before !
 

SirDice

Administrator
Staff member
Administrator
Moderator
No amount of reinstalling databases/mysql57-server is going to "fix" the issues that are present in the datafiles.

Simple question, is there any data in /var/db/mysql/? If there is data do you need to preserve it or can it be destroyed?

If you just want to start with a "fresh" clean database, then stop mysql (it probably wasn't running anyway); service mysql-server stop. Then remove everything, note that this will REMOVE any existing databases, data and whatnot, so be sure this is what you want to do; rm -rf /var/db/mysql/*. Check the permissions of /var/db/mysql directory, it should be owned by mysql:mysql. Start the service for the first time: service mysql-server start. Does that work?
 
I suggest to rename /var/db/mysql folder for preserving data. I'm not sure but I saw something similar when MySQL upgraded from 5.6 to 5.7 (as Zabbix 4 dependency). I had to reinstall 5.6, unload the database, install 5.7 and load from the dump file. Maybe it's wrong assumption.
 
Code:
root@ellamay:/usr/home/steve # rm -rf /var/db/mysql/.*
rm: "." and ".." may not be removed
root@ellamay:/usr/home/steve #

I'm root so I assume I should be able to do this.
 

SirDice

Administrator
Staff member
Administrator
Moderator
I'm root so I assume I should be able to do this.
No, you may not. You can't remove the special directories . and ... And it's rm -rf /var/db/mysql/*, not rm -rf /var/db/mysql/.*
 
Here we go.


Code:
root@ellamay:/usr/home/steve # rm -rf /var/db/mysql/.*
rm: "." and ".." may not be removed
root@ellamay:/usr/home/steve # rm -rf /var/db/mysql/*.
rm: No match.
root@ellamay:/usr/home/steve # cd /var/db/mysql/
root@ellamay:/var/db/mysql # ls
-slow.log               client-cert.pem         ib_logfile1             mysql-bin.000003        performance_schema      server-key.pem
auto.cnf                client-key.pem          ibdata1                 mysql-bin.000004        private_key.pem         sys
ca-key.pem              ib_buffer_pool          mysql-bin.000001        mysql-bin.index         public_key.pem
ca.pem                  ib_logfile0             mysql-bin.000002        mysql2                  server-cert.pem
root@ellamay:/var/db/mysql #
 
Is that *dot or * comma?

it’s neither. The command ends with /* and nothing else, so
Code:
rm -rf /var/db/mysql/*
meaning delete all files that match the * wildcard, which is everything in the folder list you posted. When you typed it with /*. It would only delete files that ended with a .
As mentioned, only do this if you are happy to delete everything in the database
 
I have regained access to mysql. Thank you so much for the help and everyones time.

It has raised a few questions:

Why was I suddenly locked out of mysql?
When I deleted mysql server Libraoffice was also removed. Why would this be?
 

SirDice

Administrator
Staff member
Administrator
Moderator
Why was I suddenly locked out of mysql?
Can't tell after the fact. Could be anything, including entering the wrong password.

When I deleted mysql server Libraoffice was also removed. Why would this be?
Because LibreOffice has a dependency on it (don't know why it needs that though).
 
Because LibreOffice has a dependency on it (don't know why it needs that though).

Interesting thread here on the subject

 
Using 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0 I had the same issue with mysql57 when running service mysql-server start there would be a message WARNING: failed precmd routine for mysql.

Following the same guides to clean the /var/db/mysql folder did not help. I found no other guides that provided any useful information, besides doing a clean install of FreeBSd. So, I resulted to tracking down the actual error by adding set -x to /usr/local/etc/rc.d/mysql-server and added --verbose to track down that my problem was the naming of the directories in the /var/db folder. InnoDB is looking for mysql-secure and mysql-tmpdir to be named mysql_secure and mysql_tmpdir.

Looking at the output of /usr/local/libexec/mysqld --verbose --help I noticed that there are variables for tmpdir and secure-file-priv that are apparently set in /sur/local/etc/mysql/my.cnf. Though, I am uncertain why MySQL does not create those directories in the /tmp folder during installation.

Additionally, I found that MySQL also failed during installation due to the timezone in my.cnf being set to "America/Los_Angeles". This seems like an issue just with installation as, mysql-server was working with this setting before I uninstalled it
 
Using 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0 I had the same issue with mysql57 when running service mysql-server start there would be a message WARNING: failed precmd routine for mysql.

Following the same guides to clean the /var/db/mysql folder did not help. I found no other guides that provided any useful information, besides doing a clean install of FreeBSd. So, I resulted to tracking down the actual error by adding set -x to /usr/local/etc/rc.d/mysql-server and added --verbose to track down that my problem was the naming of the directories in the /var/db folder. InnoDB is looking for mysql-secure and mysql-tmpdir to be named mysql_secure and mysql_tmpdir.

Looking at the output of /usr/local/libexec/mysqld --verbose --help I noticed that there are variables for tmpdir and secure-file-priv that are apparently set in /sur/local/etc/mysql/my.cnf. Though, I am uncertain why MySQL does not create those directories in the /tmp folder during installation.


Additionally, I found that MySQL also failed during installation due to the timezone in my.cnf being set to "America/Los_Angeles". This seems like an issue just with installation as, mysql-server was working with this setting before I uninstalled it

Posting this here (though the thread is marked solved, if it is ok) because at the moment I share the same problem:

# ls -ld /tmp /var/db/mysql/
drwxrwxrwt 8 root wheel 23 Jul 11 22:20 /tmp
drwxr-xr-x 6 mysql mysql 41 Jul 11 21:27 /var/db/mysql/

# pkg info | grep -i mysql
mysql80-client-8.0.29 Multithreaded SQL database (client)
mysql80-server-8.0.29 Multithreaded SQL database (server)
php80-mysqli-8.0.20 The mysqli shared extension for php

# ps -aux | grep mysql
[myname] 8184 0.0 0.5 465356 30916 - I 20:40 0:05.99 /usr/local/libexec/mysqld --defaults-file=/home/s
mysql 70530 0.0 0.0 13596 20 - Is 21:27 0:00.03 /bin/sh /usr/local/bin/mysqld_safe --defaults-ext
mysql 79657 0.0 6.8 2330976 417684 - I 21:27 0:05.71 /usr/local/libexec/mysqld --defaults-extra-file=/
root 31968 0.0 0.0 12840 1904 1 S+ 22:30 0:00.00 grep mysql

# service mysql-server start
mysql already running? (pid=xxx).

$ grep rcvar /usr/local/etc/rc.d/*
/usr/local/etc/rc.d/mysql-server:rcvar=mysql_enable

# mysql_secure_installation
mysql_secure_installation: [ERROR] unknown variable 'prompt=\u@\h [\d]>\_'.
Securing the MySQL server deployment.
Enter password for user root:
Error: Access denied for user 'root'@'localhost' (using password: YES)
 
Top