Solved

Problem after moving mysql database

Posted on 2014-10-27
4
402 Views
Last Modified: 2014-10-28
Hello,

When the IT dept set up my Linux server with MySQL they set the data directory to /var/lib/mysql

Now the system disk is full.

So there is a disk with loads of space which i have copied of the database to using:

cp /var/lib/mysql /data

then i edited the my.cnf file and changed the row that Points to the database to:

datadir = /data

I deleted some old log files to create some space.

Then i restarted the server.

But i now get an error message in mysqld.log that says:

Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist

How can i solve this?  I have seen examples that say you can use:

mysql_install_db –user=mysql –ldata=/newlocation

but i just want to be certain i am not doing a total new install by type in that command.

I know nothing about Linux/MySQL so keep you answers to beginner level!
0
Comment
Question by:soozh
  • 2
4 Comments
 
LVL 7

Assisted Solution

by:Stampel
Stampel earned 200 total points
ID: 40406836
you could just move the data and symlink /var/lib/mysql to /whatever/you/want
without changing the configuration. I have done this a couple of times for production systems.
0
 
LVL 7

Expert Comment

by:Stampel
ID: 40406842
i suspect someone could have upgraded mysql without upgrading data and you are hitting this cause you did restart mysql what nobody did before.

Usually when you it this error of missing table you would run "mysql_upgrade -p"
That would fix the problem with this table
0
 
LVL 13

Accepted Solution

by:
Sandy earned 300 total points
ID: 40407822
1. Stop MySQL using the following command:
sudo /etc/init.d/mysql stop

2. Copy the existing data directory (default located in /var/lib/mysql) using the following command:
sudo cp -R -p /var/lib/mysql /newpath

3. you already modified the "datadir" parameter

4. Restart MySQL with the command:

/etc/init.d/mysql restart

Hope this helps ... Keep posted

TY/SA
0
 

Author Closing Comment

by:soozh
ID: 40407848
Thanks for the help.  I did want sandy suggested but i had copied the wrong directory level.  So now everything is working.  Thanks for the help.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Coding C# in Linux 8 69
mysql ide 10 40
curl SSL certificate unable to get local issuer certificate 15 70
Run Secure WMI query from CentOS 5 33
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question