Solved Cannot start mysql

OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

What I don't get is why mysql clearly works for CQRlog but not for me as user "root" or "steve"
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,252
Messages: 37,426

Ok, installation is a bit of a mess with the different MySQL/MariaDB versions. Some versions log to /var/log/mysql/, some use the old /var/db/mysql/<hostname>.err. Some have configuration files in /usr/local/etc/mysql/ and some use /var/db/mysql/my.cnf. I'm a little lost it seems.

Double checking databases/mysql57-server, logging should be in /var/db/mysql/`hostname`.err. Configuration file is /var/db/mysql/my.cnf. Run service mysql-server start. If it fails to start with a 'pre-command' failure, check the permissions of /var/db/mysql/.

What I don't get is why mysql clearly works for CQRlog but not for me as user "root" or "steve"
Check if it's actually running; ps -aux | grep mysql. If it's running and there are no failures noted in the error log then the obvious reason is likely that you're not using the correct password for those accounts.
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

If it is not too far gone try connecting with either: 127.0.0.1 or localhost or its network IP
Also, check firewall
My suggestions may have been more suitable earlier on though.

Code:
root@ellamay:/ # mysql 127.0.0.1
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
root@ellamay:/ # mysql -u 127.0.0.1 -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
root@ellamay:/ #
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,252
Messages: 37,426

Code:
root@ellamay:/ # mysql 127.0.0.1
It doesn't work that way; mysql -h 127.0.0.1

Also note that your user accounts should be registered as having 127.0.0.1 as host too. Or else this isn't going to work either.

You can quickly check the users if you use the username/password of that CQRlog application, you know that works. Then look at the user table, something like select user,host from mysql.user;. This won't show you everything but at least you can check the state of the accounts and the hosts they're allowed to login from.
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

Check if it's actually running; ps -aux | grep mysql. If it's running and there are no failures noted in the error log then the obvious reason is likely that you're not using the correct password for those accounts.

Code:
root@ellamay:/ # ps -aux | grep mysql
root       2036  0.0  0.1    4940   1916  1  S+   13:05     0:00.00 grep mysql
root@ellamay:/ #

Does this mean it's running or not?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,252
Messages: 37,426

Does this mean it's running or not?
Negative.

Then run service mysql-server start, if it fails with that pre-start failure, check the permissions on /var/db/mysql/*. If it appears to start but still isn't running (check with ps(1)) look in /var/db/mysql/<hostname>.err for reasons why it might have failed.
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

mysql.user;. This won't show you everything but at least you can check the state of the accounts and the hosts they're allowed to login from.

Well there's the problem mysql.user does not exist!
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,252
Messages: 37,426

Well there's the problem mysql.user does not exist!
You can't check this if the database isn't running. What exactly are you looking at?
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

You can't check this if the database isn't running. What exactly are you looking at?

Precisely!

I can't create a user because I cannot log in.
I cannot log in because mysql will not start.

Code:
root@ellamay:/ # service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
root@ellamay:/ #

I give up!

I will remove and reinstall mysql.
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

I reinstalled mysql 5.7 and:

Code:
root@ellamay:/ # mysql_secure_installation
mysql_secure_installation: [ERROR] unknown variable 'prompt=\u@\h [\d]>\_'

Securing the MySQL server deployment.

Connecting to MySQL server using password in '/root/.mysql_secret'
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
root@ellamay:/ #

I just cannot win!!
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,252
Messages: 37,426

I just cannot win!!
You keep trying to run before you learned how to walk.

Start MySQL: service mysql-server start. That should set things up for you.
Check if it's working by logging in: mysql -p (you can find the password in the .mysql_secret file).
Change MySQL's root password; you can't do anything until you completed that step.
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

You keep trying to run before you learned how to walk.

Start MySQL: service mysql-server start. That should set things up for you.
Check if it's working by logging in: mysql -p (you can find the password in the .mysql_secret file).
Change MySQL's root password; you can't do anything until you completed that step.

I'm following the instructions detailed at https://loga.us/2020/09/15/cqrlog-install-on-freebsd/ Which worked flawlessly in the past.
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

ls -ld /tmp /var/db/mysql/

Code:
root@ellamay:/usr/home/steve # ls -ld /tmp /var/db/mysql
drwxrwxrwt  33 root   wheel  4608 26 May 14:49 /tmp
drwxr-xr-x   5 mysql  mysql  1024 26 May 14:11 /var/db/mysql
root@ellamay:/usr/home/steve #
 

fcorbelli

Active Member

Reaction score: 51
Messages: 163

You're actually doing a bit of a mess.
First you must typically have ONE mysql server installed, of a single version (and not for example a mix of mysql server-client and mariadb) - of course I am referring to unintentional use with multiple versions.

In rc.conf only the first line is required (the second is just about useless)
Code:
mysql_enable="YES"
mysql_args="--bind-address=127.0.0.1"
---
So, please,
Code:
pkg info | grep -i mariadb
pkg info | grep -i mysql

* install mysql (pkg install)
* add the first line to rc.conf (mysql_enable) or you will get "errors"
* start mysql by
service mysql-server start
(or whatever)
If you came HERE then it's possible to go .
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

So, please,
Code:
pkg info | grep -i mariadb
pkg info | grep -i mysql

* install mysql (pkg install)
* add the first line to rc.conf (mysql_enable) or you will get "errors"
* start mysql by
service mysql-server start
(or whatever)
If you came HERE then it's possible to go .

Code:
 root@ellamay:/usr/home/steve # root@ellamay:/usr/home/steve # pkg info | grep -i mariadb
root@ellamay:/usr/home/steve: Command not found.
root@ellamay:/usr/home/steve # root@ellamay:/usr/home/steve # pkg info | grep -i mysql
root@ellamay:/usr/home/steve: Command not found.
root@ellamay:/usr/home/steve #

Why the obsession with mariadb? I have never installed it in my life unless it was part of an unintentional install through another program.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,252
Messages: 37,426

Why are you copy/pasting the command line including the prompt?

Forget for a minute what that website tells you to do. Actually look and understand what you're doing. Then you might be able to solve these issues on your own the next time you run into problems. Just blindly copy/pasting some instructions from a website isn't going to help you in any way.

Again.
service mysql-server start
Does that work? If yes, login using mysql -p using the password in ~/.mysql_secret.
If that works, change the MySQL root password. Then log off.
Then run mysql_secure_installation if you really need it.
 

fcorbelli

Active Member

Reaction score: 51
Messages: 163

Code:
root@ellamay:/usr/home/steve # root@ellamay:/usr/home/steve # pkg info | grep -i mariadb
root@ellamay:/usr/home/steve: Command not found.
root@ellamay:/usr/home/steve # root@ellamay:/usr/home/steve # pkg info | grep -i mysql
root@ellamay:/usr/home/steve: Command not found.
root@ellamay:/usr/home/steve #

Why the obsession with mariadb? I have never installed it in my life unless it was part of an unintentional install through another program.
That is really strange.
Please check if grep is installed

Why mariadb check? Because it happens (all the time) exactly what you think: you install X that will require and install mariadb Y.
Then you install Z which blindly require mysql K.

For example sphinx version 2 is absolutely incompatible with mariadb: it wants the mysql-client at all costs.

Returning to us, it should be checked if and which versions of mysql / mariadb are installed
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,252
Messages: 37,426

That is really strange.
Please check if grep is installed
It's not strange, he copy/pasted the command prompt along with the commands.

Why mariadb check? Because it happens (all the time) exactly what you think: you install X that will require and install mariadb Y.
The default is set to MySQL 5.7. As long as you install everything from packages then everything will depend on MySQL 5.7 and nothing will depend on MariaDB. Things are only going haywire if you do it the other way around, install mariadb then install something that depends on a mysql client. In that case MariaDB will get removed (because it conflicts with MySQL).
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

This is what you want

Code:
root@ellamay:/usr/home/steve # pkg info | grep mysql
mysql57-client-5.7.33          Multithreaded SQL database (client)
mysql57-server-5.7.33          Multithreaded SQL database (server)
root@ellamay:/usr/home/steve # pkg info | grep mariadb
root@ellamay:/usr/home/steve #
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

Please do

service mysql-server start

Code:
$ service mysql-server status
mysql is not running.
$ service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
$
 

fcorbelli

Active Member

Reaction score: 51
Messages: 163

Can you delete the datafile of mysql (restarting from scratch) or you have something to be maintained?

You have made an upgrade from previous version of OS?
 

covacat

Well-Known Member

Reaction score: 139
Messages: 308

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

try that as root
should find nothing
 
OP
S

SAJM

Active Member

Reaction score: 12
Messages: 138

I've already reinstalled mysql twice today.
Nothing that I'm aware of has occurred to stop it starting. Well obviously something has occurred but it's beyond me.
 
Top