MySQL是一種常用的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),有時(shí)我們需要在其命令行界面輸入中文字符,但是默認(rèn)情況下,MySQL不支持中文輸入,這就需要我們切換輸入法。
$mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu) 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. mysql>
在進(jìn)入MySQL命令行界面后,如果需要輸入中文,我們可以通過以下步驟切換輸入法:
mysql>set names utf8mb4; Query OK, 0 rows affected (0.00 sec) mysql>set character_set_client=utf8mb4; Query OK, 0 rows affected (0.00 sec) mysql>set character_set_results=utf8mb4; Query OK, 0 rows affected (0.00 sec)
執(zhí)行以上代碼后,我們就可以在MySQL命令行界面中輸入中文字符了。
mysql>select * from users where username='張三';
切換輸入法可以讓我們更方便地操作MySQL,提高工作效率。