Knowledgebase

[Urgent]Mysql problem

Posted by nidhal, 01-11-2013, 06:43 AM
Hello, I have moved my website to a new server but I have a problem with Mysql, the new server is unable to find table that have a hyphen like "table-title" I would like to explain this part because I think it is important, the method I used to backup Mysql is by shuttingdown Mysql and compressed all files and than I moved them to new server, I always use this method and it works just fine. The problem is that the old server use the following file format for table with hyphen table@002dtitle.MYD But the new one was unable to read that format and use the simple way: table-title.MYD So is there anyway to force mysql to read tables data using the @002d? Or is there any command that can find and replace files name? From table@002dtitle.MYD To table-title.MYD Mysql version in the old server: 5.1.66 Mysql version in the new server: 5.0.96 Thanks! Last edited by nidhal; 01-11-2013 at 06:46 AM.

Posted by NetworkPanda, 01-11-2013, 06:46 AM
Using SSH you can go to /var/lib/mysql/database_name, rename the MYD/MYI files to use underscore (ie. table_title.MYD) and then restart MySQL and configure your application to read data from the new table name.

Posted by nidhal, 01-11-2013, 06:53 AM
Cant do that, I have like 10000 tables use the hyphen The old way to make it works is by replacing the @002d to - like this: table@002dtitle to title-title not sure if there is any command that can do that..

Posted by NetworkPanda, 01-11-2013, 07:37 AM
Yes, there is a Linux command for batch renaming files and replace one character with another. Using SSH just go to the folder where the tables are stored (/var/lib/mysql/your_database) and run this command: This will find all files with a @ in their filename and rename them by replacing the @ with a - So file table@002dtitle will become table-002dtitle file table@003dtitle will become table-003dtitle etc Then restart the MySQL service so that it reads the renamed tables (this is an important step) However I don't know if using hyphens is a good idea for MySQL tables, maybe you should consider using underscores. In this case, just type this command to replace all @ with _ in table names:

Posted by net, 01-11-2013, 07:40 AM
Moved > Hosting Security and Technology.

Posted by Skytemediahost, 01-11-2013, 07:53 AM
Nidhal - you have two options: 1: if you have the root access of the server then please read mv command tutorial - it is for move and also used for rename purposes. 2: If your old server is still alive then take db dump from mysql server. To do the db dump, please read mysqldump command tutorial.

Posted by nidhal, 01-11-2013, 07:53 AM
Thanks for your answer I was trying some command on my test vps and I got this command to work rename '@002' '-' * but I get Argument list too long I tried that but the database it too big and I was unable to take a backup using mysqldump Last edited by nidhal; 01-11-2013 at 07:57 AM.

Posted by NetworkPanda, 01-11-2013, 08:13 AM
Yes, rename command on 10000 database tables (which is 30000 files including all MYD, MYI and frm files) will give this error you got. Why didn't you try my command? Just paste it, because I understand that it is difficult to type it by hand. "For" loops always run, no matter how many files you have in any folder.

Posted by nidhal, 01-11-2013, 09:59 AM
Thanks mate, I already did it with find command



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Favorite Resellers (Views: 641)
Just starting (Views: 560)


Language:

Client Login

Email

Password

Remember Me

Search