Mysql – Run thesqld under a different user (linux)

daemonMySQL

I've been trying to start mysqld under a different user as well as with a different data path. I've done so by modifing the my.cnf file as follows:

[mysqld]
datadir=/bob/database
socket=/bob/database/mysql.sock
user=bob
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/bob/mysqld.log
pid-file=/bob/mysqld.pid

Whenever I try to start the mysql daemon by running service mysqld start two things happen

  1. I get the following error

    ERROR: 1005  Can't create table 'db' (errno: 13)
    121010 13:39:46 [ERROR] Aborting
    121010 13:39:46 [Note] /usr/libexec/mysqld: Shutdown complete
    
  2. The folder /bob/ and everything in it has mysql:mysql permissions which makes me think the user option in my.cnf did not work and because I run the service start command as root it can just chown the dir as mysql:mysql without running into any problems. At the same time when I run that command I get the following warning:

    121010 13:39:46 [Warning] Ignoring user change to 'mysql' because the user was set to 'bob' earlier on the command line
    

Any help would be greatly appreciated.

***UPDATE

If instead of having the bob user, I put the mysql user and change the permissions of the bob folder to mysql everything works fine. So this is a problem with changing the user not a different data path.

Best Answer

You may want to check init script, like /etc/init.d/mysqld or something like that, to see if it initialize mysql database with mysql user.