Hi Michael,
Thanks a lot for a very informative and educational reply.
The problem was that my base directory is /usr i.e. i have /usr/share/mysql/english.. and I was assuming it was /data/mysql or wherever i chose to put my datadir. I was clearly confused abt the concept of basedir.
So , now i have basedir /usr , datadir /data/mysql/data and all the file permissions as meant to be. i.e. datadir owned by mysql and 700. and its a beautiful feeling to see it all work :)
Thanks again for all the replies. I learned some useful stuff and suddenly the problem seems worthwhile.
Regards,
Kaustubh


----Original Message Follows----
From: Michael Stassen <[EMAIL PROTECTED]>
To: "kaustubh shinde" <[EMAIL PROTECTED]>
CC: mysql@lists.mysql.com
Subject: Re: where is my data?
Date: Mon, 04 Apr 2005 12:45:04 -0400


On Apr 2, 2005, at 7:58 AM, kaustubh shinde wrote:

Hi,
I have suse 9.2 and MySQL 4.21
My basedir is /var/lib/mysql
datadir /data/mysql/mysqldata

As it stands now, mysqld_safe is broken when you move your data directory, so this may cause problems. (See bug 7249 <http://bugs.mysql.com/bug.php?id=7249>.) In this case, however, I think this is not the problem.


Both the directories and subdirectories and files are owned by user mysql, group mysql with rights 755. So I guess I have got the permissions part right or so I hope.

datadir should be owned by mysql, group mysql, with permissions set to 700 or 750.


Everything was working fine till I decided to move the data directory from its previous location to the above one.
I had millions of problems after moving the data directory and the database won't start at all.

Exactly. Where was it before?

Just to make things work I made the base and data dirs 777. Finally, I can now start it using `mysql.server start`

Don't do that! It's insecure. If this made a difference, it means you have problems you should fix. This just hides them, and exposes your server.


But the good part ends here. I can only see mysql and test databases and i have to log on as root to mysql. My earlier users and databases won't show. Although I have the datafiles at the specified location. This might be coz I ran mysql_install_db again.

When you ran mysql_install_db, you got a new data directory in the default location (presumably the same place your data used to be) with the default dbs, mysql and test. The default mysql db has user root and the anonymous user, '', each with no password. mysqld is now working because it is using this data directory, instead of yours.


If I change the rights of base and data dirs to 755, it won't work.

This is because you've made a bad choice of location (basedir) for your log and socket files. User mysql must be able to write to the directory where these will go, but user mysql should not be able to write to basedir (basedir should be owned by root). You need to move these to a directory owned by mysql (datadir) or a directory where everyone can write (e.g. /tmp).


I still can't start using mysqld_safe.

My /etc/my.cnf has following:

[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock

/data/mysql/mysqldata/mysql.sock or /tmp/mysql.sock should work.

user=mysql
datadir=/data/mysql/mysqldata
bdb_home=/data/mysql/mysqldata

[mysql_server]
basedir = /var/lib/mysql

[mysql.server]
basedir = /var/lib/mysql

[mysqld_safe]
err-log=/var/lib/mysql/mysqld.log

/data/mysql/mysqldata/mysqld.log should work.


innodb_data_home_dir=/data/mysql/mysqldata innodb_data_file_path=ibdata1:10M:autoextend innodb_log_group_home_dir=/data/mysql/ innodb_log_arch_dir=/data/mysql/

and so on..
anyway, so this my.cnf doesn't seem to make any difference. when i try

mysqld_safe  & it gives

Starting mysqld-max daemon with databases from /var/lib/mysql

Apparently, your distribution expects the data directory to be /var/lib/mysql, but that's your basedir. Hmm...


/usr/bin/mysqld_safe: line 307: /var/lib/mysql/www.eh3.uc.edu.err: Permission denied
/usr/bin/mysqld_safe: line 313: /var/lib/mysql/www.eh3.uc.edu.err: Permission denied
STOPPING server from pid file /var/lib/mysql/www.eh3.uc.edu.pid
tee: /var/lib/mysql/www.eh3.uc.edu.err: Permission denied
050402 07:39:03 mysqld ended
tee: /var/lib/mysql/www.eh3.uc.edu.err: Permission denied



So I try mysqld_safe --user=mysql --err-log=/var/lib/mysql/mysqld.log & and I get

050402 07:40:29 mysqld started
050402 7:40:29 InnoDB: Started
050402 7:40:29 Fatal error: Can't open privilege tables: Table 'mysql.host' doesn't exist
050402 7:40:29 Aborting

Right, the data directory wasn't found.

050402  7:40:29  InnoDB: Starting shutdown...
050402  7:40:31  InnoDB: Shutdown completed
050402  7:40:31 /usr/sbin/mysqld-max: Shutdown Complete

050402 07:40:31  mysqld ended


and when i try to specify basedir with above command like
mysqld_safe --user=mysql --err-log=/var/lib/mysql/mysqld.log --basedir=/var/lib/mysql &


i get
050402 07:38:28 mysqld started
050402 7:38:28 Can't find messagefile '/var/lib/mysql/share/mysql/english/errmsg.sys'
050402 7:38:28 Aborting


050402 07:38:28  mysqld ended


Wait a minute. You don't have share in /var/lib/mysql? If you set basedir, you are telling mysqld that everything needed to run can be found in subdirectories of basedir (bin, lib, man, share, etc.)


OK, I'm guessing that this is an RPM install. /var/lib/mysql is not really your basedir, it is simply the old data directory. In that case, you need to remove all the "basedir = /var/lib/mysql" lines in your config file(s), and change the socket and log files to go in the new datadir, /data/mysql/mysqldata/. Then you ought to be able to start with just `mysqld_safe &`.

To be safe, since /var/lib/mysql is the compiled-in default location for the data directory, and you've moved your data directory to /data/mysql/mysqldata/, your best bet would probably be to remove /var/lib/mysql and replace it with a symbolic link pointing to /data/mysql/mysqldata/. That will work around anything we've missed, and it should allow a server-specific configuration file (datadir/my.cnf) to actually work.

wonderful!!!!!!!!

From what I understand, mysqld_safe is supposed to read these options from my.cnf. but its not and i have to specify them on command line.

It is, but the incorrect settings confused it.

I have spent 4 days and sacrificed an enticing surfing trip on this and feel like I'm the dumbest guy on face of earth. every problem seem to spawn off a new one as soon as its solved..

Ouch. Well, I'd suggest research before action, and asking a question of the list at the first problem, rather than after 4 days of frustration.


I will really appreciate if someone could just point out the exact problem to me and give a direction.

Thanks in advance
Kaustubh

Michael

_________________________________________________________________
The MSN Survey! http://www.cross-tab.com/surveys/run/test.asp?sid=2026&respid=1 Help us help you better!



-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to