Shell startup script for mysql issues solved

tony33

Active Member

Reaction score: 4
Messages: 132

Hi, I noticed I can start mysql directly from the bin file etc. The startup script that come with mysql is not running properly.

I would type in terminal service mysql-server start and this is what it will spit out:

Code:
ld-elf.so.1:  Shared object "libedit.so.7" not found. required by "sh"
path to startup script here then : Warning: failed  to start mysql

I understand it's saying it cannot find libedit.so.7 but I looked in the directory of /lib/libedit.so.7 and it's there.
So, I have no clue why the script cannot find this file? Does anyone got any suggestions on what I can do so the script can locate this file?
 

im

Member

Reaction score: 35
Messages: 82

your shell 'sh' seems like broken.

run the command "ldd `which sh`" or "ldd /bin/sh" and compare the output.
Code:
ldd `which sh`
/bin/sh:
        libedit.so.7 => /lib/libedit.so.7 (0x800849000)
        libc.so.7 => /lib/libc.so.7 (0x800a83000)
        libncursesw.so.8 => /lib/libncursesw.so.8 (0x800e3a000)

Show me the output of:
Code:
uname -a
file /bin/sh
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,630
Messages: 36,301

I suspect it's the same issue as the thread I linked, a corrupted /var/run/ld-elf.so.hints.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

your shell 'sh' seems like broken.

run the command "ldd `which sh`" or "ldd /bin/sh" and compare the output.
Code:
ldd `which sh`
/bin/sh:
        libedit.so.7 => /lib/libedit.so.7 (0x800849000)
        libc.so.7 => /lib/libc.so.7 (0x800a83000)
        libncursesw.so.8 => /lib/libncursesw.so.8 (0x800e3a000)

Show me the output of:
Code:
uname -a
file /bin/sh
I typed in ldd /bin/sh

it gave me this:
Code:
     libedit.so.7 =>  /lib/libedit.so.7 (0x80026e000)
     libc.so.7=> /lib/libc.so.7 (0x8002aa000)
      libncursesw.so.8=> /lib/libncursesw.so.8 (0x8006a3000)

That's what I got so far.

The output of :

uname -a
file /bin/sh

is :
Code:
freebsd  tony33.com  12.1-RELEASE-p8  FreeBSD 12.1-RELEASE-p7 GENERIC amd64

file /bin/sh
/bin/sh: ELF 64-bit LSB executable. x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for  FreeBSD 12.1, FreeBSD-style, stripped
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

I suspect it's the same issue as the thread I linked, a corrupted /var/run/ld-elf.so.hints.

How would I fix this then? what commands to run. I can boot my machine. I do have access to terminal.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

Run these commands:
/rescue/ldconfig /lib /usr/lib /usr/local/lib
/rescue/ldconfig -32 /usr/lib32 /usr/local/lib32/compat

That should probably fix it.


I ran them and then tried service mysql-server start and I get the same error message.
After I ran the commands you posted There was no error or anything shown when running those commands.

It's just when I did the mysql part it still shows the same error I posted in the original post.
 

im

Member

Reaction score: 35
Messages: 82

Please try to run /bin/sh
Does the error appears again?
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

Please try to run /bin/sh
Does the error appears again?
When I type in /bin/sh

it starts the shell:
#

I can type in echo and echo out text there's no error message at all.

However, if I do service my sql-server start the error shows up.

I don't see the error at all when running /bin/sh from terminal.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

Please try to run /bin/sh
Does the error appears again?
The thing is that /bin/sh works like I can run it and other scripts like service postfix works... I don't get any errors.

It's only when I type service mysql-server start that it spits out the error.
 

richardtoohey2

Well-Known Member

Reaction score: 250
Messages: 468

The service code is just a shell script (if I'm looking at the right thing):
Code:
% head /usr/sbin/service
#!/bin/sh

# $FreeBSD: releng/12.2/usr.sbin/service/service.sh 335029 2018-06-13 06:11:04Z imp $

# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
#
#  Copyright (c) 2009 Douglas Barton
#  All rights reserved.
If you make a file called /tmp/script.sh and put these two lines in it:
Code:
#!/bin/sh
echo hello
Make it executable:
Code:
% chmod u+x /tmp/script.sh
And run it:
Code:
% /tmp/script.sh
Do you get the same error? EDIT: Oops, just re-read what you said about other service <name> stuff working, so don't think I'm saying much useful.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

The service code is just a shell script (if I'm looking at the right thing):
Code:
% head /usr/sbin/service
#!/bin/sh

# $FreeBSD: releng/12.2/usr.sbin/service/service.sh 335029 2018-06-13 06:11:04Z imp $

# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
#
#  Copyright (c) 2009 Douglas Barton
#  All rights reserved.
If you make a file called /tmp/script.sh and put these two lines in it:
Code:
#!/bin/sh
echo hello
Make it executable:
Code:
% chmod u+x /tmp/script.sh
And run it:
Code:
% /tmp/script.sh
Do you get the same error? EDIT: Oops, just re-read what you said about other service <name> stuff working, so don't think I'm saying much useful.

I followed your instructions.
I made the script.sh in the tmp folder and made it executable.

There was no error at all. When I ran that script it just output the word hello in terminal and that was it.
I see no error at all.

after doing this. I tried again service mysql-server and I get that same error only when I run this. The error I posted in the original post only shows up when doing service mysql-server start.

I can do service x start any other service and it would run without any errors. It's just I only get the error posted in my original post only when I run service mysql-server start.
If I manually start mysql it will work with no errors at all but I don't like going to the directory for mysql and then putting the commands to start the server.

I have it setup that at startup the mysql script runs but that fails in the background. I just want this fixed and after the error in my original post there's another statement form the script the it failed to start mysql.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,630
Messages: 36,301

Try rebooting the machine. I'm sure there's something cached somewhere and you keep hitting that same failure because of it.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

Try rebooting the machine. I'm sure there's something cached somewhere and you keep hitting that same failure because of it.
I just tried that and got the same results. I shutdown the server. Then unplugged the power and waited 5 minutes and replugged it back in and started the server back up.
it booted into sh and I type in service mysql-server start and gave me the same error message as in original post.

I then ran the script.sh followed above and no errors. I can do service postfix start and it works. I don't get these errors. I can service any server software and it works other than mysql-server. The myseql-server is the only thing that spits this out.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

Hang on. What do you mean? You got stuck in single user mode?
I didn't get stuck I meant when the system restarted and boot. It boot into sh and not into terminal. I did /bin/csh to get back to terminal.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,630
Messages: 36,301

It boot into sh and not into terminal.
So you got the Enter full pathname of shell or RETURN for /bin/sh: message? That means you got stuck in single user mode because of an error. What was the exact error?
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

So you got the Enter full pathname of shell or RETURN for /bin/sh: message? That means you got stuck in single user mode because of an error. What was the exact error?
No, I got nothing. I meant before when I booted my machine it would show terminal like :
Code:
 username@domain: / #

Yet, when I restarted the computer and it booted back up I got this screen :
Code:
  #
which never did this before even when I made this thread.
It would always boot into something like
Code:
 user@domain: / #

I don't know if that's single user mode and if that's the case then yes but this is something new. This didn't happened before I followed the instructions on the commands to use to fix the problem.
but if I do /bin/csh it changes terminal back to this format:
Code:
  user@domain: /  #
 
Last edited:

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,630
Messages: 36,301

I meant before when I booted my machine it would show terminal like
That's after you logged on? Remember, we can't see what's on your screen and what you are doing. That makes it really difficult for us to follow what's happening if you skip information or use the wrong (or unclear) terminology.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

That's after you logged on? Remember, we can't see what's on your screen and what you are doing. That makes it really difficult for us to follow what's happening if you skip information or use the wrong (or unclear) terminology.
I understand. I am saying after you told me to reboot my machine.
the walk thru

Yes, this is after I logged on.
My machine would boot freebsd and ask to login. I would login as root.

So, my machine before you asked me to reboot my machine. The way my machine would work.
After it boots freebsd and asks for username and password. I would login as root.
it would show on the terminal screen after logging in to be like
Code:
 root@domain /:  #
that's what it would look like.

Now after logging in as root after you asked me to reboot my machine and this is again after I logged in as root.
It would show the terminal to be just
Code:
 #

I don't know if this is called single user or if it means much. I just noticed this difference.

I would have to type in like this
Code:
 # /bin/csh

to get the terminal screen back to showing something like
Code:
  root@domain: / #
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,630
Messages: 36,301

I suspect at some point you changed root's shell. Look at getent passwd root, specifically look at the shell that's configured. I suspect you set this to /bin/sh. The default shell for root is normally /bin/csh. You can change this easily with the chsh(1) command. While it's typically recommended not to change root's shell it's fine of you change it to one of the shells of the base system. As long as you don't change it to a shell that's installed by a port or package (bash, ksh, zsh, etc). The reason for this is that during a major upgrade important libraries may get updated before you get a chance to update your ports/packages. You would then more or less lock yourself out because those third-party shells usually crash or fail to work when this happens.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

I suspect at some point you changed root's shell. Look at getent passwd root, specifically look at the shell that's configured. I suspect you set this to /bin/sh. The default shell for root is normally /bin/csh. You can change this easily with the chsh(1) command. While it's typically recommended not to change root's shell it's fine of you change it to one of the shells of the base system. As long as you don't change it to a shell that's installed by a port or package (bash, ksh, zsh, etc). The reason for this is that during a major upgrade important libraries may get updated before you get a chance to update your ports/packages. You would then more or less lock yourself out because those third-party shells usually crash or fail to work when this happens.
you're right and I changed it back to csh.

I ran mysql and it works with no errors at all. It's just only the errors show up when using the service script.

Now I am using csh and when I type in service mysql-server stop it spits this error out: ld-elf.so.1: shared object "libncursesw.so.8" not found, required by "csh"

that is what it's now saying. before that error message it would show a message: stopping mysql

that lib does exist in /lib/libncursesw.so.8. I even ran the ldd /bin/csh and it does list that it found libncursesw.so.8.

Do you think it's possible this error is shown due to permission issues?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,630
Messages: 36,301

Do you think it's possible this error is shown due to permission issues?
Not on a standard install at least. Unless you changed the permissions on various directories.
 
OP
tony33

tony33

Active Member

Reaction score: 4
Messages: 132

Not on a standard install at least. Unless you changed the permissions on various directories.
well I had a backup of the server before I was practicing to backup and restore dumps. So, clean the drive and then done a backup and during this process when the OS booted there was a ton of permission issues. I had to change permissions to directories and files to get the OS to boot and many other things. Same went with server software. I still don't know how this happened but I got things to be working but I think there still some permission issues lingering somewhere and I am not sure if this is what's causing this issue that I am having. However, what confuses me is why is shell complaining about libedit and csh complaining ncurses? if it's a permission issues I would think both would have complained about the same libs. got any ideas what I can check?
 
Top