LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-28-2003, 10:12 PM   #1
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 209

Rep: Reputation: 32
MySQL database directory


Hello.

I'm relatively new at databases so if this is a stupid question I apologize.

Here is my setup:
I have 2 hard drives on my Redhat 9.0 box. The primary drive is a 60GB which I use as the 'main' OS drive which contains '/'. The second drive is a 200GB drive which I mount as '/data'.

My goal is to install a binary copy of MySQL on the 60GB under '/usr/local/mysql' as per the MySQL manual. However, because of the size of the database I'm working with, I need to store the database on the 200GB drive.

My question is this: Is there a way to tell MySQL to use the database located on the 200GB drive?

Thanks.
 
Old 10-29-2003, 05:49 AM   #2
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
I haven't tried it but I guess it should be possible either by chaning the datadir in your my.cnf, compiling it with that dir as the default (but you aren't compiling so...) or invoking mysql with the --datadir=/data parameter

I guess you'll have to make sure the access permissions are set up right for /data too.

Someone must have set it up like that but you might aswell try it.
 
Old 10-29-2003, 09:19 AM   #3
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 209

Original Poster
Rep: Reputation: 32
I'll try invoking myql --datadir=/data that might just work.

Thanks.
 
Old 10-29-2003, 09:38 AM   #4
lenlutz
Member
 
Registered: May 2003
Location: philadelhpia pa
Posts: 92

Rep: Reputation: 15
i could be full of it, but, in /etc/my.cnf
set mysql-data-dir="/path_to_your_db"
(not the db itself, just the dir its in)
 
Old 12-05-2003, 05:18 PM   #5
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 209

Original Poster
Rep: Reputation: 32
MySQL...Here we go again...

Okay the good news first: I got this to work on Redhat.
The bad news is that my boss just switched to slackware so I have to do this all over again.
ARRRRGGGG!!!


Now here are the steps I took:
I downloaded the compiled binary for linux from mysql.com and typed the following commands:
groupadd mysql
useradd -q mysql mysql
tar -xzvf mysql-*.tar.gz
mv mysql-* /usr/local
cd /usr/local
ln -s /usr/local/mysql-* mysql
cd mysql
scripts/mysql_install_db
chown -R root .
chown -R mysql data
chgrp -R mysql .
chown -R mysql /data
chgrp -R mysql /data

vi /etc/my.cnf
## contents of my.cnf ##
[mysqld]
datadir=/data ##200GB maxtor drive where I want to store the databases
socket=/tmp/mysql.sock
port=3306
user=mysql
## end my.cnf ##

cp support-files/mysql-server /etc/rc.d/rc.mysqld

vi /etc/rc.d/rc.mysqld
## changed the default datadir to be /data ##
datadir=/data
## end changes to /etc/rc.d/rc.mysqld ##

./bin/mysqld_safe --users=mysql &

Now this starts and then quits with no errors. I look at the linuxbox.err file that is created in /data and this is what it contains:

031206 18:08:00 mysqld started
Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line
031206 18:08:01 InnoDB: Started
031206 18:08:01 Fatal error: Can't open privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
031206 18:08:01 Aborting

031206 18:08:01 InnoDB: Starting shutdown...
031206 18:08:03 InnoDB: Shutdown completed
031206 18:08:03 /usr/local/mysql/bin/mysqld: Shutdown Complete

031206 18:08:03 mysqld ended

This happens every time and I can't figure out why! The file it's complaining about is in the mysql folder created by mysql_install_db script. If I change all the 'datadir=' enteries to point to /usr/local/mysql/data everything works.

So 2 questions:
1 what is going on?
2 Can I some how fix this so that the default data directory is /data and not /usr/local/mysql/data
 
Old 12-06-2003, 03:02 PM   #6
diegofalciola
LQ Newbie
 
Registered: Dec 2003
Posts: 26

Rep: Reputation: 15
Mysql Database Access

I think i have the solution to your problem, cause a few minutes ago, I was installing mysql and i had the same problem.

The matter is file rights. if you do an ls -l in the mysql directory, you will see that there is no access from the user to that directory
when u set file rights, you should also set file rights to the files that are in "data" directory. for example, to host.frm. this may be done doing chmod 777 *.* (this is the easiest way, not the one i recommend, for security questions).

hope this help!
 
Old 12-06-2003, 09:49 PM   #7
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 209

Original Poster
Rep: Reputation: 32
THANK YOU!!! It worked Yippeee!!!!
 
Old 12-06-2003, 11:54 PM   #8
diegofalciola
LQ Newbie
 
Registered: Dec 2003
Posts: 26

Rep: Reputation: 15
=)

u're welcome!
 
  


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
Writing an app that uses a mysql database without installing mysql server? QtCoder Programming 4 08-09-2004 02:43 PM
cannot connect to mysql database mrosati Linux - Software 19 07-15-2004 02:40 PM
MYSQL help - mysql database missing eloviyandhi Linux - Software 1 03-20-2004 09:20 PM
Mysql database from cd JHuizingh Linux - Software 0 02-22-2003 02:08 PM
mysql database huno Linux - General 8 02-11-2003 08:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 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
Open Source Consulting | Domain Registration