Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mounting a database

Status
Not open for further replies.

Crundy

Programmer
Jul 20, 2001
305
GB
Hi all,
I have an existing mysql database on a disk, and I want to mount the disk in the databases directory and start mysql to get the database back to where it was from a snapshot.

I'm using this script:

/etc/init.d/mysqld stop
mkdir /var/lib/mysql/mydbname/
chown mysql /var/lib/mysql/mydbname/
chgrp mysql /var/lib/mysql/mydbname/
mount /dev/sdg /var/lib/mysql/mydbname/
/etc/init.d/mysqld start
mysql -u root --execute "grant all on mydbname.* to 'username'@'localhost' identified by 'mypassword'"

This seems at first glance to work, but then certain queries fail saying that a particular table does not exist. Running SHOW TABLES does list the table in question so do I presume correctly that the files have become corrupted?

Is it not possible to mount the files on a disk as above? Do I need to run off a dump file every time?

C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!
 
I cannot see any reason this would not work... but sounds suspiciously like a permissions problem ... may be the way you are approaching this.

The location of the database files is controlled by a variable that can be set in the my.cnf or on the command line ... look for datadir=. So while standard install of mysql tends to store all the database tables within the same directory structure as the package like /var/lib/mysql .. one of the first things I always do after setting root passwords is set up a datadir like /test_area/mysqldata and /release/mysqldata and copy over the mysql subdirectory or database that holds the permissions database and meta data... as you have done take care to chmod and chown. Then easy to switch between test and release by simply changing my.cnf and restarting database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top