mysql update from a text file?

February 19, 2010 - 7:19 am

I am trying to update a field in mysql database. The update statement is long and DOS Command always truncates the last portion. If I paste the statement in a text file, how to execute the file. My mySql is 3.x version. Thanks

IF I understand correctly, just create the update in a plain text file save it with name update.sql (as an example..). Then from the DOS window, or any shell do:

mysql -u user -p databasename < update.sql

It will prompt you for your password.

And that’s it. Be sure to take some time to browsw through mysql docs, also if posible update to a newer version, you are missing a whole lot of stuff with 3.x

Alex

One Response to “mysql update from a text file?”

  1. alexR Says:

    IF I understand correctly, just create the update in a plain text file save it with name update.sql (as an example..). Then from the DOS window, or any shell do:

    mysql -u user -p databasename < update.sql

    It will prompt you for your password.

    And that’s it. Be sure to take some time to browsw through mysql docs, also if posible update to a newer version, you are missing a whole lot of stuff with 3.x

    Alex
    References :

Leave a Reply