LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Start MySQL with a non-default datadir (https://www.linuxquestions.org/questions/linux-enterprise-47/start-mysql-with-a-non-default-datadir-298848/)

nifflerX 03-07-2005 04:23 PM

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

acid_kewpie 03-07-2005 04:43 PM

can you run mysql with a few -v's on the command line for a little more information?

nifflerX 03-07-2005 04:53 PM

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

acid_kewpie 03-07-2005 04:56 PM

sorry for the confusion, i meant the mysqld_safe daemon.

nifflerX 03-07-2005 04:59 PM

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

nifflerX 03-08-2005 09:24 AM

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

nifflerX 03-08-2005 10:17 AM

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

edudirectories 02-09-2006 07:13 PM

its because rhel 4 has selinux installed with it You need to disable it

try

setsebool -P mysqld_disable_trans=1

laggerific 02-27-2006 11:07 AM

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.

edudirectories 02-28-2006 05:42 AM

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.


All times are GMT -5. The time now is 06:49 PM.