Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've just upgraded to MySQL 4.0.16-0 from 3.23 using RPM. Now, the mysql server shuts down as soon as it starts up. The following appears in /var/log/mysqld.log
060503 21:46:42 mysqld started
Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists!
060503 21:46:42 Aborting
The "mysql" user is supposed to be a system user. You probably should delete the mysql regular user before proceeding.
Then create a mysql group. You will need to do that first to create a new mysql system user who's primary group is "mysql".
You need to add a system user by the name "mysql" with the default group of "mysql" and the default shell of /bin/bash. Do not include a password, so that the account is locked.
The entry for the home page should be "/var/lib/mysql"
My entry for the mysql user looks like this:
mysql:x:60:103:MySQL database admin:/var/lib/mysql:/bin/bash
Your uid and gid will be different of course.
The first two columns of the mysql entry in /etc/shadow will look like this:
mysql:!:
The "!" character means that someone can't log into this account.
Seeing as the rpm installation is supposed to create the user and group, I deleted the user (the group was deleted automatically when I did this) and ran the installs again. The user is created exactly as jschiwal says it should be (above) and the group is there as well. Both have system ids.
The installation automatically starts the server... and it shuts down again with the same error in the log.
I can write a program that switches to user 'mysql' (below).
Could it be that mysqld complains that it can't when the problem is actually something else?
int main(void)
{
struct passwd *pwEntry;
pwEntry = getpwnam("mysql");
printf("User id of mysql is %d\n", pwEntry->pw_uid);
if (setuid(pwEntry->pw_uid)) {
perror("setuid ");
return 1;
}
printf ("Set uid to %d OK\n", pwEntry->pw_uid);
return 0;
}
Output:
# ./setuid
User id of mysql is 100
Set uid to 100 OK
I've created a new start-up script that calls the real one as the user mysql.
This is mymysql:
#!/bin/sh
#This is my cludge. If the normal mysql script is run as root, mysqld fails to switch user for some reason.
#This script executes the other script as mysql
case "$1" in
'start')
sudo -u mysql /etc/init.d/mysql start
;;
'stop')
sudo -u mysql /etc/init.d/mysql stop
;;
'restart')
sudo -u mysql /etc/init.d/mysql restart
;;
esac
I've changed the link /etc/rc5.d/S90mysql to link to /etc/init.d/mymysql.
I'd still like to know why mysqld was failing to switch user to mysql when started by root, though.
I realize that I may be one of the few left supporting MySQL 4.0 deployments, but it may be of use to others who stumble onto this thread. We just moved our product from MySQL 4.0.16 on RedHat AS3 to 4.0.27 on AS5 and got bit by this "feature".
The MySQL AB built distributions are (were?) statically linked "to increase portability across distributions". Further, it seems that at some point around 4.0.20 they began building their binaries with the Intel compiler suite rather than GCC.
MySQL 4.0.16 worked fine for our product on both AS3 and AS5, but as soon as we moved to 4.0.27 on AS5 it would no longer start. We saw the "unable to change to mysql user"-type errors. Digging into the source code, getpwent() appeared to be failing.
My best guess is that something changed in NSS or PAM or something between AS3 and AS5. Since MySQL was statically linked against whatever was available in the distant past, it did not pick up the new "knowledge" it needed to interact correctly on newer systems.
As a "fix", I had to rebuild the 4.0.27 RPMs with the static linking disabled. This allowed it to pick up the correct behavior from libc, and viola! 4.0.27 now starts correctly -- without the su init script hack -- on AS5.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.