samedi 28 février 2015

How to call this shell script to convert mysqldump to SQLite compatible syntax

I need to autonomously convert mysqldump files (.sql file) to SQLite compatible .sql files. I found this script on github which is supposed to be able to do this. If I had an unmodified .sql file from MySQL called test.sql whose database's name was test and the script mysql2sqlite.sh in a directory, how would I call it.


The script says in the comments how to call it. I believe my scenario matches the first one titled usage because I already have the mysqldump file.



# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite


I read in the comments on the github page to change the scripts permissions with chmod +x mysql2sqlite.sh so navigated to the directory with the sql and the script and did that. Then I tried:


pi@raspberrypi ~ $ ./mysql2sqlite.sh test.sql test | sqlite3 database.sqlite


It failed with the error: -bash: ./mysql2sqlite.sh: /bin/sh^M: bad interpreter: No such file or directory


I then read online that to call an .sh file you type sh myShellFile.sh


So I tried sh mysql2sqlite.sh test.sql test | sqlite3 database.sqlite and got back:



: not founde.sh: 2: mysql2sqlite.sh:
: not founde.sh: 5: mysql2sqlite.sh:
: not founde.sh: 8: mysql2sqlite.sh:
: not founde.sh: 11: mysql2sqlite.sh:
: not founde.sh: 13: mysql2sqlite.sh:
: not founde.sh: 14: mysql2sqlite.sh:
mysqldump: Got error: 1045: Access denied for user 'pi'@'localhost' (using password: NO) when trying to connect
: not founde.sh: 15: mysql2sqlite.sh:


It appears that its trying to connect to a server rather than reading the mysqldump file that I provided. What is the proper way to call this script. I have some experience with Linux and no experience with unix shells.


It may be of some use to read the background of my problem


Aucun commentaire:

Enregistrer un commentaire