You can use:
mysql --defaults-file=file_name
to specify a defaults file per database.
See https://dev.mysql.com/doc/refman/8.0/en/password-security-user.html
for the various options for supplying passwords.
Chris
Chris
On Fri, Oct 26, 2018 at 05:37:13PM -0400, Andy Borka wrote:
This is not exactly what I am looking for. I need to create bash scripts** To leave the list, click on the immediately-following link:-
that will access the mysql client to perform queries against any named
database, which could require any number of username/password combinations.
How would I do this?
On 10/26/18 10:24 AM, Chris Nestrud wrote:
You can put the username and password in ~/.my.cnf, then use something like:** To leave the list, click on the immediately-following link:-
echo "select c1, c2, c3 from table" | mysql --database database_name
See https://mariadb.com/kb/en/library/configuring-mariadb-with-mycnf/
Chris
On Fri, Oct 26, 2018 at 10:03:31AM -0400, Andy Borka wrote:
Hi,** To leave the list, click on the immediately-following link:-
Someone asked me to create a test bash script that will perform sql
queries
against a mysql database and return the results to a bash terminal. I
can't
figure out how to provide usernames and passwords in the first line.
## the following line works, but provides a login error.
#!/usr/bin/env mysql
...
# The following never works because env can't find the executable.
#!/usr/bin/env mysql -u username -pPassword
# The above returns bash: mysql -u username -pPassword not found.
Any ideas on how I can get this to work?
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq