2

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.

3
  • Make sure the /bob/ folder has the permissions to read and write Commented Oct 10, 2012 at 18:07
  • @Stranger it does. Permissions are 777 for testing purposes. Commented Oct 10, 2012 at 18:10
  • if you use centos/redhat it could be a selinux issue.. if you use ubuntu it might be apparmour. Commented May 10, 2015 at 5:30

3 Answers 3

1

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.

1
  • Yes: in /etc/init.d/mysql, su - mysql -s /bin/bash -c "mysqld_safe > /dev/null &" should be changed to su - bob -s /bin/bash -c "mysqld_safe > /dev/null &" Commented Apr 13, 2016 at 22:14
0

i think changing the user in the mysql-config has only effect when the mysqld is started during the boot process - see here

1
  • I think what they were trying to say was that if you wanted mysqld to automatically run as that user on startup you would have to change the mysql-config file. Regardless if I restart it, mysql doesn't care if its during boot process or not, it will follow the same steps. Commented Oct 10, 2012 at 18:20
0

As Jerome explained we have to change one more file

etc/init.d/mysql
su - mysql -s ... become su - bob -s ...

but with Ubuntu 18.04 we also need to change this one...

/etc/systemd/system/multi-user.target.wants/mysql.service
user=mysql become user=bob

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.