###前提・実現したいこと
タイトルのとおりです。
シェルスクリプトの中でMySQLにアクセスし、ユーザー情報を表示したいです。
以下のコマンドから得られる結果をシェルスクリプトから表示したいです。
mysql> select User from mysql.user; +---------+ | User | +---------+ | devuser | | root | +---------+ 2 rows in set (0.00 sec)
###発生している問題
root@19787b71ebdc:/# mysql -u root -pverysecret -h $MYSQL_PORT_3306_TCP_ADDR mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 16 Server version: 5.7.14 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
###該当のソースコード
#!/bin/sh commandMysql_User=`mysql -u root -pverysecret -h $MYSQL_PORT_3306_TCP_ADDR -e select User from mysql.user;` echo "$commandMysql_User"
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
DockerのMySQLイメージから作成したContainerを扱っています。
接続はこのコマンドで行っています。
docker run --link db_server:mysql -it --rm mysql bash
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/02 06:18