LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 03-07-2005, 04:23 PM   #1
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Rep: Reputation: 16
Start MySQL with a non-default datadir


Hi,

I've just installed RedHat Enterprise WS v4 with both MySQL client and server rpms. The default installation sets the datadir at /var/lib/mysql. I would like the data directory to instead by /home/mysql (home is a larger partition). First, let me point out that if I change nothing from the default install and run /etc/init.d/mysqld start, everything works and I can access mysql. However, when I go and edit the file /etc/my.cnf bad things begin to happen. First I stopped the mysql damean, then I edited the /etc/my.cnf file so it looked like:
Code:
[mysqld]
datadir=/home/mysql
socket=/home/mysql/mysql.sock
                                                                                
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
                                                                                
[mysql.server]
user=mysql
basedir=/home
                                                                                
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Then I moved the directory /var/lib/mysql to /home so it was /home/mysql. Then I tried to restart the mysql damean and got the following error:
Quote:
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]
If I try and run the command mysqld_safe directly, I get the following error:
Quote:
Starting mysqld daemon with databases from /home/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
050307 16:20:45 mysqld ended
After all this, if I change my /etc/my.cnf file back to the original and move the /home/mysql directory back to /var/lib I can start the mysql damean without a problem. Does anyone know what I'm doing wrong and what I need to do in order to move my data directory? Thanks so much.


-NifflerX
 
Old 03-07-2005, 04:43 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
can you run mysql with a few -v's on the command line for a little more information?
 
Old 03-07-2005, 04:53 PM   #3
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Original Poster
Rep: Reputation: 16
Thanks for replying.

When I try to run mysql with my /etc/my.cnf file looking as it does above I get the following:
Quote:
mysql -vvv
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Which I suppose isn't too surprising since I can't start the mysql damean with my /etc/my.cnf file like that. The thing that bothers me is that it is still looking for the mysql socket at /var/lib/mysql/mysql.sock.

When I reset the /etc/my.cnf file to the original I get the following:
Quote:
mysql -vvv
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 4.1.7

Reading history-file /home/people/xmeadow/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Writing history-file /home/people/<username>/.mysql_history
Bye
Let me know if there is more info I can give that would be more useful. Thanks so much.


-NifflerX
 
Old 03-07-2005, 04:56 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
sorry for the confusion, i meant the mysqld_safe daemon.
 
Old 03-07-2005, 04:59 PM   #5
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Original Poster
Rep: Reputation: 16
No problem. Here's the results of the mysqld_safe command with /etc/my.cnf as above:

Quote:
sudo mysqld_safe -vvv
Starting mysqld daemon with databases from /home/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
050307 16:58:44 mysqld ended

Here's the results with /etc/my.cnf as the original:
Quote:
sudo mysqld_safe -vvv
Starting mysqld daemon with databases from /var/lib/mysql
Please let me know if there's more info I can give. Thanks again so much.

-NifflerX

Last edited by nifflerX; 03-07-2005 at 05:02 PM.
 
Old 03-08-2005, 09:24 AM   #6
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Original Poster
Rep: Reputation: 16
Hi,

I'm still working on the same problem as before, and I've currently got the my.cnf file looking as it does above, with the datadir=/home/mysql. However, today when I ran /etc/init.d/mysqld start I got a very different error response. I've posted it below.
Quote:
sudo /etc/init.d/mysqld start
Initializing MySQL database: Installing all prepared tables
050308 9:21:15 [Warning] Can't create test file /home/mysql/tesla.lower-test
/usr/libexec/mysqld: Can't change dir to '/home/mysql/' (Errcode: 13)
050308 9:21:15 [ERROR] Aborting

050308 9:21:15 [Note] /usr/libexec/mysqld: Shutdown complete

Installation of system tables failed!

Examine the logs in /home/mysql for more information.
You can also try to start the mysqld daemon with:
/usr/libexec/mysqld --skip-grant &
You can use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:

shell> /usr/bin/mysql -u root mysql
mysql> show tables

Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /home/mysql that may be helpful.

The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
[FAILED]
chown: cannot access `/var/lib/mysql': No such file or directory
Does this new error message shed any light on what's wrong with my mysql setup? Thanks for all the help so far.


-NifflerX
 
Old 03-08-2005, 10:17 AM   #7
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Original Poster
Rep: Reputation: 16
This isn't exactly a solution, but here is what I did to finally get it to work. I downloaded that latest stable version from mysql.com and installed that as per the instructions. Then I started mysql. It ran without a problem from the datadir I definted in /etc/my.cnf. I'm not sure what the problem was, but for whatever reason, the mysql that came installed via the redhat installation disks just would not work.

-NifflerX
 
Old 02-09-2006, 07:13 PM   #8
edudirectories
LQ Newbie
 
Registered: Feb 2006
Posts: 9

Rep: Reputation: 0
its because rhel 4 has selinux installed with it You need to disable it

try

setsebool -P mysqld_disable_trans=1

Last edited by edudirectories; 02-09-2006 at 07:16 PM.
 
Old 02-27-2006, 11:07 AM   #9
laggerific
Member
 
Registered: Jan 2006
Posts: 65

Rep: Reputation: 15
When I moved my data directory, the only setting I changed in the config file was the location of the data directory. I didn't modify anything else. I also made sure that the new data directory had the same permissions as the default data directory. All went well after that.
 
Old 02-28-2006, 05:42 AM   #10
edudirectories
LQ Newbie
 
Registered: Feb 2006
Posts: 9

Rep: Reputation: 0
Yeah but the newer version of linux has selinux installed. If that is it uses user mysqld_t which doesnt have permissions there. You can either shut selinux off totally - use the command i said or you will need to reflag files.
 
  


Reply



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
Starting MySQL OLD Error : imeout error occurred trying to start MySQL Daemon Fr33B5D Linux - Software 9 10-28-2006 06:23 AM
mySQL my.cnf (moving default datadir) not working! madfitz Linux - Newbie 4 02-09-2006 07:15 PM
MySql error 2002, Cannot start mysql djchris Linux - Software 5 04-13-2004 06:12 PM
difference between localstatedir and datadir Robin01 Linux - Newbie 1 11-17-2003 05:49 PM
/usr/local/games/datadir? boku Programming 1 11-27-2002 08:34 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 12:04 AM.

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
Open Source Consulting | Domain Registration