Uly.me

cloud engineer

  • Home
  • About
  • Archives
You are here: Home / Linux / Run SQL in Bash

March 10, 2019

Run SQL in Bash

Here’s an example on how to run MySQL commands from Bash.

mysql dbname -e "UPDATE wp_options SET option_value='http://domain.com' WHERE option_name='home'";
mysql dbname -e "UPDATE wp_options SET option_value='http://domain.com' WHERE option_name='siteurl'";

mysql dbname -e "UPDATE wp_options SET option_value='http://domain.com' WHERE option_name='home'"; mysql dbname -e "UPDATE wp_options SET option_value='http://domain.com' WHERE option_name='siteurl'";

The example updates WordPress’ home and siteurl. Script contains no password. It’s using .my.cnf config file.

Filed Under: Linux, WP Tagged With: .my.cnf, bash, mysql, sql, wordpress

  • Home
  • About
  • Archives

Copyright © 2019