LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2012, 02:31 PM   #1
mmorton89
LQ Newbie
 
Registered: Jul 2012
Location: Columbus, OH
Distribution: Centos 6.3
Posts: 20

Rep: Reputation: Disabled
Having troubles changing the database directory for mysql


Hello, I have been trying to change the directory of my databases for mysql with no success.

I have changed the directories in /etc/my.cnf to the new directory.
Code:
[mysqld]
# datadir=/var/lib/mysql
# socket=/var/lib/mysql/mysql.sock
datadir=/home/mc/mysql
socket=/home/mc/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
I changed the owner and permissions for the folder and everything in the folder.
Code:
[root@localhost ~]# ls -l /home/mc/mysql
total 266272
drwx------. 2 mysql mysql      4096 Nov  6 01:32 creativecontrol
-rwx------. 1 mysql mysql 262144000 Nov  6 01:32 ibdata1
-rwx------. 1 mysql mysql   5242880 Nov  6 01:32 ib_logfile0
-rwx------. 1 mysql mysql   5242880 Nov  6 01:32 ib_logfile1
drwx------. 2 mysql mysql      4096 Nov  6 01:32 iconomy
drwx------. 2 mysql mysql      4096 Nov  6 01:32 jobs
drwx------. 2 mysql mysql      4096 Nov  6 01:32 logblock
drwx------. 2 mysql mysql      4096 Nov  6 01:32 lwc
drwx------. 2 mysql mysql      4096 Nov  6 01:32 mysql
drwx------. 2 mysql mysql      4096 Nov  6 01:32 towny
Yet when I try to start the mysqld service I get this in the mysql.log

Code:
121106 02:10:56 mysqld_safe Starting mysqld daemon with databases from /home/mc/mysql
121106  2:10:56 [Warning] Can't create test file /home/mc/mysql/localhost.lower-test
121106  2:10:56 [Warning] Can't create test file /home/mc/mysql/localhost.lower-test
121106  2:10:56  InnoDB: Initializing buffer pool, size = 8.0M
121106  2:10:56  InnoDB: Completed initialization of buffer pool
121106  2:10:56  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
121106 02:10:56 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
I am clueless to why it does not have permissions in the directory? I gave ownership and 700 permissions on that directory.
 
Old 11-05-2012, 04:22 PM   #2
Obscurious
LQ Newbie
 
Registered: Jun 2009
Distribution: Debian, RHEL, FreeBSD
Posts: 17

Rep: Reputation: 0
From the logfile it really looks to be a permission problem. My guess is that the mysql user can't write to some file or directory in /home/mc/mysql. Double check all your permissions, even hidden files and make sure to chmod recursively.

1) What operating system are you running? This is important.
2) Have you migrated the pre-existing database data?
 
Old 11-05-2012, 05:31 PM   #3
mmorton89
LQ Newbie
 
Registered: Jul 2012
Location: Columbus, OH
Distribution: Centos 6.3
Posts: 20

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Obscurious View Post
From the logfile it really looks to be a permission problem. My guess is that the mysql user can't write to some file or directory in /home/mc/mysql. Double check all your permissions, even hidden files and make sure to chmod recursively.

1) What operating system are you running? This is important.
2) Have you migrated the pre-existing database data?
1) CentOS 6
2) Yes I copied the whole directory with
Code:
cp -R /var/lib/mysql/ /home/mc/mysql/
 
Old 11-05-2012, 06:37 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,250

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Looks lie SELinux
Code:
cd /var/lib/mysql
$ ls -lZ
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 console
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 console_auth
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 console_inventory_service
-rw-rw----. mysql mysql system_u:object_r:mysqld_db_t:s0 ibdata1
-rw-rw----. mysql mysql system_u:object_r:mysqld_db_t:s0 ib_logfile0
-rw-rw----. mysql mysql system_u:object_r:mysqld_db_t:s0 ib_logfile1
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql
srwxrwxrwx. mysql mysql system_u:object_r:mysqld_var_run_t:s0 mysql.sock
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 test
If you use cp, the file inherit the SELinux setting of the new parent dir. mv would have kept the original settings.
In any case, why would you want to do this; its only going to cause confusion/issues...
 
Old 11-05-2012, 06:50 PM   #5
mmorton89
LQ Newbie
 
Registered: Jul 2012
Location: Columbus, OH
Distribution: Centos 6.3
Posts: 20

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Looks lie SELinux
Code:
cd /var/lib/mysql
$ ls -lZ
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 console
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 console_auth
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 console_inventory_service
-rw-rw----. mysql mysql system_u:object_r:mysqld_db_t:s0 ibdata1
-rw-rw----. mysql mysql system_u:object_r:mysqld_db_t:s0 ib_logfile0
-rw-rw----. mysql mysql system_u:object_r:mysqld_db_t:s0 ib_logfile1
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql
srwxrwxrwx. mysql mysql system_u:object_r:mysqld_var_run_t:s0 mysql.sock
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 test
If you use cp, the file inherit the SELinux setting of the new parent dir. mv would have kept the original settings.
In any case, why would you want to do this; its only going to cause confusion/issues...
well my /var directory in on my first hard drive which is only a 64 GB SSD and I want mysql to save its databases on my 500 GB HDD.

This seemed like the easiest way to get the databases on my HDD since my /home directory is on my 2nd hard drive.

Also I just assumed, since I am running a game server, that if I put mysql on my second hard drive it would help because the game server is running off the SSD and using the HDD for mysql would help reduce the I/O usage on the SSD.

Last edited by mmorton89; 11-05-2012 at 06:52 PM.
 
Old 11-05-2012, 07:31 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,243

Rep: Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624
mysql is being started as the user mysql. I would guess that even though mysql might have permissions to /home/mc/mysql it still does not have permissions to access /home/mc. I would not suggest changing your users home directory permissions.

It is possible to run mysqld as any regular user. Be sure to change the msqld data permissions appropriately for whatever user you choose.

http://dev.mysql.com/doc/refman/5.5/...ysql-user.html
 
Old 11-05-2012, 07:37 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,250

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
I'd move the whole of /var to go on the HDD in that case; that's where the logs for everything go. Its gets a lot of i/o usage.
 
Old 11-06-2012, 06:33 AM   #8
mmorton89
LQ Newbie
 
Registered: Jul 2012
Location: Columbus, OH
Distribution: Centos 6.3
Posts: 20

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
I'd move the whole of /var to go on the HDD in that case; that's where the logs for everything go. Its gets a lot of i/o usage.
How would I do that?

I tried to look up how to move directories to another hard drive but I could not figure out how to, so I resorted to this. That would make things a whole lot simpler.

Last edited by mmorton89; 11-06-2012 at 06:38 AM.
 
Old 11-06-2012, 12:25 PM   #9
mmorton89
LQ Newbie
 
Registered: Jul 2012
Location: Columbus, OH
Distribution: Centos 6.3
Posts: 20

Original Poster
Rep: Reputation: Disabled
Should I make a new thread? For asking how to move the /var directory?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
postfix +Cyrus SASL authentication problem + pam-mysql+mysql database kibirango Slackware 1 12-25-2012 09:47 AM
How can i copt the MYSQL Database to a other server (Database) halvorls Linux - Server 3 07-27-2008 10:19 PM
MySQL - Needed enforcing of a user defined directory for the database. Nimoy Programming 1 10-25-2007 10:25 AM
MySQL won't change database directory techker Linux - Software 2 10-04-2006 02:11 PM
MySQL database directory GATTACA Programming 7 12-07-2003 12:54 AM


All times are GMT -5. The time now is 11:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration