mysqlimportmysql-error-1146mysql-error-1044mysql-error-1046

mysql import trouble using XAMP


originally i was using easyPHP (windows) then i switch to mac and used MAMP. i archive my db every once in a while and right before i reformatted. The export was made by going into the root of phpMyAdmin and using the export function. Now i am trying to import the data i get this error "#1044 - Access denied for user 'root'@'localhost' to database 'information_schema'". Doing other things i got errors like "#1146 - Table 'test_db.COLLATION_CHARACTER_SET_APPLICABILITY' doesn't exist", "#1146 - Table 'test_db.CHARACTER_SETS' doesn't exist " and "#1146 - Table 'test_db.COLUMNS' doesn't exist" and "#1046 - No database selected"

How do i get MAMP to import and ignore any access errors and continue so my DB is filled to the previous state? I rather not write an app to do this but if i had to what libs would i use to parse the sql statements in the sql dump? It doesnt look hard to parse. It looks like a semicolon separates the statements. But what about escape and unescape issues? how do i handle that?


Solution

  • The first error indicates that something is very wrong with your setup. information_schema is an internal DB which keeps data about other parts of the system (meta-data). You should try reinstalling your MySQL server (or even MAMP as a whole).

    Second of all: the dump files can be imported using the mysql command line client like this:

    mysql -p -u root test_db < dump.sql
    

    One thing to remember is that "test_db" needs to be created before the dump is restored. An other possible problem might be that the dump/restore is being done by different versions of MySQL (ie. 5.0 vs 5.1). For this you could try the --force command in the mysql command line to skip over failed executions, however be aware that this might not correctly restore your data.