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
# * 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 ?
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 :)
|All times are GMT -5. The time now is 04:09 PM.|