LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-23-2007, 03:01 PM   #1
Nimoy
Member
 
Registered: Jun 2003
Location: Currently Denmark
Distribution: Ubuntu 11.10
Posts: 334

Rep: Reputation: 30
MySQL - Needed enforcing of a user defined directory for the database.


Doing a MySQL Java DB project and I would like to be able to decide on where MySQL creates it's databases for backup purposes.

I have tried to go into the /etc/mysql/my.cnf file and have altered the line datadir = /var/lib/mysql to /home/ep/5sem/database as I have seen this suggested.

It did not work.

Tried to save the file as .my.cnf, didn't work either as suggested.

Tried to rename the my.cnf to mmy.cnf also so that it would not interfere with the previously changed file, sadly I could start MySQL, but the database file was created in the /var/lib/mysql directory.... So here I am...

Reebooted the system every time I made a change.

Also tried mysqladmin -u root -p shutdown
Enter password: ***

The DB stopped - But the changes in the datadir = had the following effect when I tried to restart.

mysql -u root -p
Enter password: ***

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)



Version info: mysql Ver 14.12 Distrib 5.0.38, for pc-linux-gnu (i486) using readline 5.2


Excerpt from my.cnf

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
# datadir = /var/lib/mysql
datadir = /home/ep/5sem/database
tmpdir = /tmp
language = /usr/share/mysql/english

Any suggestions on how to force MySQL to use the directory /home/ep/5sem/database to save all information to ?

Last edited by Nimoy; 10-23-2007 at 05:04 PM. Reason: Adding additional information
 
Old 10-25-2007, 09:25 AM   #2
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 198

Rep: Reputation: 30
Hmmm, not exactly a programming question but wth. You are doing it right. All that needs to be done is datadir parameter changed and all the data files moved to the new location. Though, you must keep in mind these few things :

- new directory exists at the moment you start db
- your mysql database was copied to the new directory (just copy the files)
- your server really uses the file that you are modifying

In the case you have already deleted your old mysql db - which basically means that you lost all your users and settings - you need to recreate it. Use mysql_install_db script to do it. Once done, make sure you have proper ownership on these drectories (mysql.mysql). If none of above works - call ghostbusters
 
  


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
mySQL deny user access to database blizunt7 Programming 3 10-10-2007 09:34 AM
MySQL won't change database directory techker Linux - Software 2 10-04-2006 01:11 PM
creat MySQL database for each user ? Data-Base Suse/Novell 3 03-07-2005 02:42 PM
FYI: Creating User Defined Functions for MySQL mchirico LinuxQuestions.org Member Success Stories 1 06-11-2004 08:51 PM
MySQL database directory GATTACA Programming 7 12-06-2003 11:54 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration