How would I go about updating MySQL database X, table Y and column Z with "abc". How would I be able to do this without having to do so interactively from the mysql> prompt? I want to do this with one simple command.

1 Answer 1


First, create a password for your user to prevent use in on scripts:

mysql_config_editor set --login-path=local --host=localhost --user=user --password # you will be asked for the password.

Then, from a script or terminal, use something like this:

mysql --login-path=local --database=X -e "update Y set column Z='abc';"

Or, you can use the insecure way:

mysql --user=user --password=pass --host=localhost --database=X -e "update Y set column Z='abc';"
  • Thanks. But is it possible to do it with mysql -u user -pPASSWORD Query??
    – Teddy77
    May 28, 2015 at 16:13
  • Sure, I updated my answer.
    – jherran
    May 28, 2015 at 16:17
  • I am getting the following error ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'column userid='abc'' at line 1
    – Teddy77
    May 28, 2015 at 16:54
  • That's an error in your SQL syntax. Maybe you wrote incorrectly the field name or something like that. Can't answer with such information.
    – jherran
    May 28, 2015 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .