First a word of warning: **This works for me, it does not have to work for you**. Why use mysql interactively when you are interested only in one or two queries. It's much quicker to give you SQL query on command line. The problem is if you don't want to specify password interactively but would like to pass it on command line as well. It's possible but not safe so it's better to use a safer way to do it. Before you can do it you have to use only once `mysql_config_editor` to set a variable `login_path`like this: mysql_config_editor set --login-path=<login_path_name> --host=<hostname> --user=<username> --password In most cases your `<hostname>` will be `localhost` and `<username>` will be `root` so it can look e.g. like this mysql_config_editor set --login-path=myhostalias --host=localhost --user=root --password Then, when prompted you have to enter password for the mysql user you specified with `--user` option. After you registered your `hostalias` you can use `mysql` client without specifying password on command line. You don't have to use `-u` and `-p` to specify user and password, you just specify `--login-path` option with the variable set before e.g like this: mysql --login-path=myhostalias mydatabase -e "select body from posts where id=20;"
author | helcim |
---|---|
permlink | linux-absolute-beginners-1-how-to-safely-run-mysql-queries-on-command-line |
category | linux |
json_metadata | {"tags":["linux","tips","opensource","mysql","sql"],"app":"steemit/0.1","format":"markdown"} |
created | 2019-06-07 20:36:51 |
last_update | 2019-06-08 05:51:21 |
depth | 0 |
children | 1 |
last_payout | 2019-06-14 20:36:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.023 HBD |
curator_payout_value | 0.004 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,291 |
author_reputation | 210,624,982,764,214 |
root_title | "Linux Absolute Beginners #1 : How to safely run mysql queries on command line" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 0 |
post_id | 86,233,147 |
net_rshares | 52,494,646,690 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
jacekw | 0 | 12,740,157,760 | 50% | ||
droida | 0 | 9,617,615,071 | 100% | ||
penderis | 0 | 13,451,865,573 | 100% | ||
mylka | 0 | 2,839,711,665 | 100% | ||
sergino | 0 | 544,567,531 | 4% | ||
wglenz | 0 | 6,820,600,852 | 100% | ||
joelpugapt | 0 | 1,328,635,084 | 100% | ||
sqlguy | 0 | 5,151,493,154 | 100% |
Now that's great. Thanks for sharing.
author | sqlguy |
---|---|
permlink | psrw7k |
category | linux |
json_metadata | {"tags":["linux"],"app":"steemit/0.1"} |
created | 2019-06-08 09:11:45 |
last_update | 2019-06-08 09:11:45 |
depth | 1 |
children | 0 |
last_payout | 2019-06-15 09:11:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 37 |
author_reputation | 7,175,710,013 |
root_title | "Linux Absolute Beginners #1 : How to safely run mysql queries on command line" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,260,776 |
net_rshares | 954,719,180 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
helcim | 0 | 954,719,180 | 100% |