Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2722

stdin is not a ttyとなった時の対応方法

$
0
0
  • 環境
    • Windows 10 Pro 64bit バージョン1909
    • GitBash(mintty 3.1.0)

事象 : GitBashでwinptymysqlコマンドをリダイレクトして使ったら怒られた

$ winpty mysql -u ponsuke -p-D sampledb -P 3306
stdin is not a tty

原因 : (多分)対話モードにできないから

TTYというのは対話で入力したりできるようにしてくれるものらしい・・・
TTY(テレタイプ端末)とは - IT用語辞典 e-Words

で、いくつかのコマンドではwinptyをくっつけないと対話モードにできない・・・からMySQLにログインするときに使っていた。
Git for WindowsでPythonがうまく動かない場合の対処法 - Qiita

が、「ログインするのにパスワード入力を対話でする」「リダイレクトでファイルの内容を実行する」が一気にきて「意味ぷーーー」になったのかもしれない(多分そんなことじゃないけど)。
MySQL Git Bash winpty mysqldump stdout is not a tty and stdin is not a tty - Stack Overflow

どなたか、正しい原因を教えてください。

対応 : ログインしてからファイルの内容を実行する

# 1. ログインする$ winpty mysql -u ponsuke -p-D sampledb -P 3306
Enter password: *******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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.

# 2. ファイルの内容を実行する
mysql> source input.ddl
Query OK, 0 rows affected (0.00 sec)
...省略...

やってないけどほかの対応方法


Viewing all articles
Browse latest Browse all 2722

Trending Articles