Have you just installed Slackware 9.1 and now see a MySQL error at the login prompt?


NOTE (23 November 2003): There's a quicker way to do the below and I just found this out. In a shell or xterm, type 'su mysql' (you have to be logged in as superuser to use the mysql login) to log into the mysql user account, then run 'mysql_install_db'. This will create the needed databases and set their permissions properly. Of course, if you want to use the below methods, feel free, as both solutions work and the only difference is that one solution is quicker than the other.

OK. This is a problem. I usually swear by Slackware and I hate seeing errors like this. If you don't use MySQL then you can ignore the error. If you do plan on using it, you'll need to fix this.

It's basically an owner and group permissions problem. When Slackware installs MySQL, it gives the databases "mysql" and "test" the wrong ownership and group permissions, which MySQL complains about when attempting to start.

Here's my fix:

su to root: root@slackbox:/var/lib/mysql# su -

Enter your root password when prompted.

Go to /var/lib/mysql: root@slackbox:/var/lib/mysql# cd /var/lib/mysql

Display the directory contents: root@slackbox:/var/lib/mysql# ls -l

You'll see that the mysql/ and test/ directories have 'root' as both owner and group permissions:

root@slackbox:/var/lib/mysql# ls -l
total 20564
-rw-rw----    1 mysql    mysql       25088 Oct 11 04:02 ib_arch_log_0000000000
-rw-rw----    1 mysql    mysql     5242880 Oct 18 08:07 ib_logfile0
-rw-rw----    1 mysql    mysql     5242880 Oct 11 04:02 ib_logfile1
-rw-rw----    1 mysql    mysql    10485760 Oct 18 08:07 ibdata1
drwxrwxrwx    2 root     root         4096 Oct 18 08:05 mysql/
-rw-rw----    1 mysql    root         6945 Oct 18 08:07 slackbox.err
drwxrwxrwx    2 root     root         4096 Oct 18 08:05 test/

Some of you may even be missing one or both of these databases. When I installed Slackware 9.1 on my laptop, the 'test' database was missing. This can be fixed by entering "mysql_install_db" at the shell prompt.

Once this is done (if you had no databases), you need to set the permissions and ownership:

root@slackbox:/var/lib/mysql# cd ..
root@slackbox:/var/lib/# chown -R mysql mysql/
root@slackbox:/var/lib/# chgrp -R users mysql/ test/

Then, "ls -l /var/lib/mysql/" and you should see this:

-rw-rw----    1 mysql    mysql       25088 Oct 11 04:02 ib_arch_log_0000000000
-rw-rw----    1 mysql    mysql     5242880 Oct 18 08:07 ib_logfile0
-rw-rw----    1 mysql    mysql     5242880 Oct 11 04:02 ib_logfile1
-rw-rw----    1 mysql    mysql    10485760 Oct 18 08:07 ibdata1
drwxrwxrwx    2 mysql    users        4096 Oct 18 08:05 mysql/
-rw-rw----    1 mysql    users        6945 Oct 18 08:07 slackbox.err
drwxrwxrwx    2 mysql    users        4096 Oct 18 08:05 test/

All this corrects the MySQL error. All that's left is starting the MySQL daemon, which is done like so:

root@slackbox:/var/lib/mysql# /etc/rc.d/rc.mysqld start

or

root@slackbox:/var/lib/mysql# /usr/bin/mysqld_safe & (the first method worked for me while this command didn't)

Now, if you execute a 'ps aux | grep mysql', you'll see this:

root@slackbox:/var/lib/mysql# ps aux | grep mysql
root      3877  0.0  0.1  2068 1012 pts/1    S    08:07   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/run/mysql/mysql.pid
mysql     3895  0.0  1.6 47060 13124 pts/1   S    08:07   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysql/mysql.pid --skip-locking
root@slackbox:/var/lib/mysql#

If you've gotten this far, you'll need to make sure your MySQL daemon is secure by password protecting it:

/usr/bin/mysqladmin -u root -h toshi password entermypasswordhere
This concludes the repair job required to rid yourself of the MySQL error at the login prompt.

Any feedback or corrections can be directed here. ** (Substitute 'AT' in the email address with '@' when attempting to email)**


Copyright 2003, 2004 Ron Sinclair (Substitute 'AT' in the email address with '@' when attempting to email)
Revised: 14 January 2004
URL: http://www.unixfool.com

This page generated by Quanta 3.0, an HTML editor for Linux

This site is hosted by http://www.jtan.com


Valid CSS!

Valid HTML 4.0!