LoginSignup
ConectTheDots314
@ConectTheDots314

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

vscodeのターミナルで日本語は入力できるがmysql> の後で日本語だけ表示できない

1. やりたい・やりたかったこと

テーブルから出身地が「東京都」の人を抽出したい

2. 起きている問題やエラーメッセージ

ターミナルで

mysql> SELECT * FROM users WHERE city = '東京都'

このように打って表示させたいが、mysql> の後で日本語だけ表示できない(ターミナルでは問題なく日本語入力できます。)

3. 自身で試したこと

vscodeのターミナルでは漢字が文字化けせずに出た

しかしターミナルでは問題ないが
https://gyazo.com/1b76bdca3f58227d90a6878cdebc54a0

mysql だとそもそも入力できない(読み込まれない)
https://gyazo.com/0aae971574659b7f8dab85742539dd62

mysqlで日本語入力すると消えてしまう件を調べる
https://motomotosukiyaki.com/cant-input-japanese-in-mysql
↑の記事を参考にしてみる

https://gyazo.com/bc9fc72db9465934b423f4aec9603717
上のように

my.cnf


[mysqldump]
default-character-set=utf8mb4

[client]
#default-character-set=utf8mb4

[mysql]
#default-character-set=utf8mb4

[mysqld]
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

と[client] と [mysql] の部分をコメントアウトする

再起動 →だめ

export LC_ALL=ja_JP.UTF-8
export LANG=ja_JP.UTF-8

こちらも試したがダメ

ターミナル

bash-4.2# mysql -u root -p -D curriculumDB
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.7.41 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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> SELECT * FROM users WHERE city = ''

おそらくmysqlの文字コードが怪しいと思っています・・

4. 関連するソースコードやスクリーンショット

localeした場合

shouminotaku@shouminakunoAir 2-DB % locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
0

No Answers yet.

Your answer might help someone💌