dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.44k stars 662 forks source link

Can mycli support UTF8 ? #273

Closed aa1143 closed 7 years ago

aa1143 commented 8 years ago

can mycli support options this 【--default-character-set=utf8 】 ?

i try then get error msg : Error: no such option: --default-character-set

j-bennet commented 8 years ago

mycli does not copy all options exactly from mysql. Current list of available options:

Usage: mycli [OPTIONS] [DATABASE]

Options:
  -h, --host TEXT               Host address of the database.
  -P, --port INTEGER            Port number to use for connection. Honors
                                $MYSQL_TCP_PORT
  -u, --user TEXT               User name to connect to the database.
  -S, --socket TEXT             The socket file to use for connection.
  -p, --password TEXT           Password to connect to the database
  --pass TEXT                   Password to connect to the database
  --ssl-ca PATH                 CA file in PEM format
  --ssl-capath TEXT             CA directory
  --ssl-cert PATH               X509 cert in PEM format
  --ssl-key PATH                X509 key in PEM format
  --ssl-cipher TEXT             SSL cipher to use
  --ssl-verify-server-cert      Verify server's "Common Name" in its cert
                                against hostname used when connecting. This
                                option is disabled by default
  -v, --version                 Version of mycli.
  -D, --database TEXT           Database to use.
  -R, --prompt TEXT             Prompt format (Default: "\t \u@\h:\d> ")
  -l, --logfile FILENAME        Log every query and its results to a file.
  --defaults-group-suffix TEXT  Read config group with the specified suffix.
  --defaults-file PATH          Only read default options from the given file
  --auto-vertical-output        Automatically switch to vertical output mode
                                if the result is wider than the terminal
                                width.
  -t, --table                   Display batch output in table format.
  --warn / --no-warn            Warn before running a destructive query.
  --local-infile BOOLEAN        Enable/disable LOAD DATA LOCAL INFILE.
  --login-path TEXT             Read this path from the login file.
  --help                        Show this message and exit.
amjith commented 8 years ago

@aa1143 Although we don't currently have that as a command line option you can still specify that in the ~/.my.cnf file as follows:

[client]
default-character-set=utf8

It will be honored by mycli.

mikedfunk commented 8 years ago

This config option does not work for me. I still get errors like:

'ascii' codec can't encode character u'\u201c' in position 195: ordinal not in range(128)

The same query works fine in the mysql prompt.

amjith commented 8 years ago

@mikedfunk Can you give me a bit more details? Such as what version of mycli are you using and what command did you run?

Also what's the output that you get from mysql?

tsroten commented 7 years ago

I'm closing this since there hasn't been a response in awhile. Feel free to comment and open it back up as needed. We're happy to help out with any issues you run into :)

goshan commented 7 years ago

hi, i'm getting a error like: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128) with query select * from cms limit 2; But i can get what i want in mysql like

mysql> select * from cms limit 2;
+--------+--------------+------------------------------------------+--------------------+----------------------------------------------------------------------------+--------+-------------------------------------+------------------------------+
| id     | industry     | advertiser                               | brand              | title                                                                      | cm_dur | character                           | url                          |
+--------+--------------+------------------------------------------+--------------------+----------------------------------------------------------------------------+--------+-------------------------------------+------------------------------+
| 717852 | 生活用品     | アース製薬                               | アース製薬         | ゴキジェット「国際害虫会議」篇                                             |     15 |                                     |                              |
| 748275 | 住宅         | ダイワハウス/大和ハウス工業              | ダイワハウス       | ダイワハウス「共創共生 美しきふるまい 金沢」篇 60秒                        |     60 | 松本若菜、(声)大竹しのぶ            | https://youtu.be/9ZgU7tcdUVk |
+--------+--------------+------------------------------------------+--------------------+----------------------------------------------------------------------------+--------+-------------------------------------+------------------------------+
2 rows in set (0.00 sec)

here is my mycli status

mysql root@localhost:tvi_prj2_sys> status
--------------
mycli 1.10.0, running on CPython 2.7.13

+----------------------+-----------------------------+
| Connection id:       | 214                         |
| Current database:    | tvi_prj2_sys                |
| Current user:        | root@localhost              |
| Current pager:       | stdout                      |
| Server version:      | 5.7.12 Homebrew             |
| Protocol version:    | 10                          |
| Connection:          | localhost via TCP/IP        |
| Server characterset: | utf8                        |
| Db characterset:     | utf8                        |
| Client characterset: | utf8                        |
| Conn. characterset:  | utf8                        |
| TCP port:            | 3306                        |
| Uptime:              | 1 day 6 hours 37 min 27 sec |
+----------------------+-----------------------------+

This may be there are some japanese characters in my results. so could mycli support utf-8?

tsroten commented 7 years ago

@goshan Hello! I'm sorry you're having trouble with this. Mycli does support UTF-8, so let's try to figure this out. Can you please show us your locale's encoding by running this in your terminal?

echo ${LANGUAGE:-none} && echo ${LC_ALL:-none} && echo ${LC_CTYPE:-none} && echo ${LANG:-none}
goshan commented 7 years ago

@tsroten Hi, thanks for replying. I got some output like this after using command you told me

$ echo ${LANGUAGE:-none} && echo ${LC_ALL:-none} && echo ${LC_CTYPE:-none} && echo ${LANG:-none}
none
none
ja_JP.UTF-8
ja_JP.UTF-8

So should I set LANGUAGE and LC_ALL to ja_JP.UTF-8 ?

meeuw commented 7 years ago

I would like to reproduce this, could you please give us a (mysql)dump for the cms table? mysqldump tvi_prj2_sys cms --where "id in (717852, 748275)"

goshan commented 7 years ago

@meeuw okay. here is all my output from dump

$ mysqldump -uroot tvi_prj2_sys cms --where "id in (717852, 748275)"
-- MySQL dump 10.13  Distrib 5.7.12, for osx10.11 (x86_64)
--
-- Host: localhost    Database: tvi_prj2_sys
-- ------------------------------------------------------
-- Server version       5.7.12

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `cms`
--

DROP TABLE IF EXISTS `cms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `cms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `industry` varchar(255) DEFAULT NULL,
  `advertiser` varchar(255) DEFAULT NULL,
  `brand` varchar(255) DEFAULT NULL,
  `title` varchar(255) DEFAULT NULL,
  `cm_dur` int(11) DEFAULT NULL,
  `character` varchar(255) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `index_cms_on_advertiser_and_brand` (`advertiser`,`brand`)
) ENGINE=InnoDB AUTO_INCREMENT=1309732 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `cms`
--
-- WHERE:  id in (717852, 748275)

LOCK TABLES `cms` WRITE;
/*!40000 ALTER TABLE `cms` DISABLE KEYS */;
INSERT INTO `cms` VALUES (717852,'生活用品','アース製薬','アース製薬','ゴキジェット「国際害虫会議」篇',15,'',''),(748275,'住宅','ダイワハウス/大和ハウス工業','ダイワハウス','ダイワハウス「共創共生 美しきふるまい 金沢」篇 60秒',60,'松本若菜、(声)大竹しのぶ','https://youtu.be/9ZgU7tcdUVk');
/*!40000 ALTER TABLE `cms` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2017-05-19 17:01:47
tsroten commented 7 years ago

@goshan Try setting LC_ALL to ja_JP.UTF-8:

export LC_ALL='ja_JP.UTF-8'

Then, in the same terminal, run mycli and see if the output changes.

The problem seems to be that Python is deciding to use ascii as the default encoding. As far as I know, Python bases this off of one's locale settings.

meeuw commented 7 years ago

Thanks for posting the database dump, it works for me (on Linux):

$ LC_CTYPE=ja_JP.UTF-8 LANG=ja_JP.UTF-8 mycli
Version: 1.10.0
Chat: https://gitter.im/dbcli/mycli
Mail: https://groups.google.com/forum/#!forum/mycli-users
Home: http://mycli.net
Thanks to the contributor - Heath Naylor
mysql root@172.17.0.2:(none)> select * from dmtest.cms
+--------+----------+-----------------------------+--------------+-----------------------------------------------------+--------+--------------------------+------------------------------+
| id     | industry | advertiser                  | brand        | title                                               | cm_dur | character                | url                          |
+--------+----------+-----------------------------+--------------+-----------------------------------------------------+--------+--------------------------+------------------------------+
| 717852 | 生活用品 | アース製薬                  | アース製薬   | ゴキジェット「国際害虫会議」篇                      | 15     |                          |                              |
| 748275 | 住宅     | ダイワハウス/大和ハウス工業 | ダイワハウス | ダイワハウス「共創共生 美しきふるまい 金沢」篇 60秒 | 60     | 松本若菜、(声)大竹しのぶ | https://youtu.be/9ZgU7tcdUVk |
+--------+----------+-----------------------------+--------------+-----------------------------------------------------+--------+--------------------------+------------------------------+
2 rows in set
Time: 0.002s

Could you post the output from python -m sysconfig ? Maybe Python is compiled without unicode support or something like that.

goshan commented 7 years ago

@tsroten @meeuw It still not works for me with LC_CTYPE=ja_JP.UTF-8 LANG=ja_JP.UTF-8 mycli or export LC_ALL='ja_JP.UTF-8'. Here is my output about python -m sysconfig, it's a little long so i've no idea about which variable is the key.

Paths:
        data = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7"
        include = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7"
        platinclude = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7"
        platlib = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
        platstdlib = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7"
        purelib = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
        scripts = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin"
        stdlib = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7"

Variables:
        AC_APPLE_UNIVERSAL_BUILD = "0"
        AIX_GENUINE_CPLUSPLUS = "0"
        AR = "ar"
        ARFLAGS = "rc"
        ASDLGEN = "./Parser/asdl_c.py"
        ASDLGEN_FILES = "./Parser/asdl.py ./Parser/asdl_c.py"
        AST_ASDL = "./Parser/Python.asdl"
        AST_C = "Python/Python-ast.c"
        AST_C_DIR = "Python"
        AST_H = "Include/Python-ast.h"
        AST_H_DIR = "Include"
        ATHEOS_THREADS = "0"
        BASECFLAGS = "-fno-strict-aliasing -fno-common -dynamic"
        BASEMODLIBS = ""
        BEOS_THREADS = "0"
        BINDIR = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/bin"
        BINLIBDEST = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7"
        BLDLIBRARY = ""
        BLDSHARED = "clang -bundle -undefined dynamic_lookup"
        BUILDEXE = ".exe"
        BUILDPYTHON = "python.exe"
        CC = "clang"
        CCSHARED = ""
        CFLAGS = "-fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes"
        CFLAGSFORSHARED = ""
        CONFIGFILES = "configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in"
        CONFIG_ARGS = "'--prefix=/usr/local/opt/python' '--enable-ipv6' '--datarootdir=/usr/local/opt/python/share' '--datadir=/usr/local/opt/python/share' '--enable-framework=/usr/local/opt/python/Frameworks' '--without-ensurepip' '--without-gcc' 'MACOSX_DEPLOYMENT_TARGET=10.11' 'CC=clang' 'PKG_CONFIG_PATH=/usr/local/opt/sqlite/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.11'"
        CONFINCLUDEDIR = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include"
        CONFINCLUDEPY = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7"
        COREPYTHONPATH = ":plat-darwin:plat-mac:plat-mac/lib-scriptpackages:lib-tk:lib-old"
        COVERAGE_INFO = "/private/tmp/python-20170404-12873-188zj3c/Python-2.7.13/coverage.info"
        COVERAGE_REPORT = "/private/tmp/python-20170404-12873-188zj3c/Python-2.7.13/lcov-report"
        COVERAGE_REPORT_OPTIONS = "--no-branch-coverage --title "CPython lcov report""
        CPPFLAGS = "-I. -IInclude -I./Include"
        CXX = "clang++"
        C_THREADS = "0"
        DESTDIRS = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7 /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload"
        DESTLIB = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7"
        DESTPATH = ""
        DESTSHARED = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload"
        DIRMODE = "755"
        DIST = "README ChangeLog configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Include Lib Misc Demo Ext-dummy"
        DISTDIRS = "Include Lib Misc Demo Ext-dummy"
        DISTFILES = "README ChangeLog configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in"
        DLINCLDIR = "."
        DLLLIBRARY = ""
        DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 = "0"
        DOUBLE_IS_BIG_ENDIAN_IEEE754 = "0"
        DOUBLE_IS_LITTLE_ENDIAN_IEEE754 = "1"
        DYNLOADFILE = "dynload_shlib.o"
        ENABLE_IPV6 = "1"
        ENSUREPIP = "no"
        EXE = ""
        EXEMODE = "755"
        EXTRAMACHDEPPATH = ":plat-mac:plat-mac/lib-scriptpackages"
        EXTRAPLATDIR = "plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \"
        EXTRATESTOPTS = ""
        EXTRA_CFLAGS = ""
        FILEMODE = "644"
        FLOCK_NEEDS_LIBBSD = "0"
        GETPGRP_HAVE_ARG = "0"
        GETTIMEOFDAY_NO_TZ = "0"
        GLHACK = "-Dclear=__GLclear"
        GNULD = "no"
        GRAMMAR_C = "Python/graminit.c"
        GRAMMAR_H = "Include/graminit.h"
        GRAMMAR_INPUT = "./Grammar/Grammar"
        HAVE_ACOSH = "1"
        HAVE_ADDRINFO = "1"
        HAVE_ALARM = "1"
        HAVE_ALLOCA_H = "1"
        HAVE_ALTZONE = "0"
        HAVE_ASINH = "1"
        HAVE_ASM_TYPES_H = "0"
        HAVE_ATANH = "1"
        HAVE_ATTRIBUTE_FORMAT_PARSETUPLE = "0"
        HAVE_BIND_TEXTDOMAIN_CODESET = "0"
        HAVE_BLUETOOTH_BLUETOOTH_H = "0"
        HAVE_BLUETOOTH_H = "0"
        HAVE_BROKEN_NICE = "0"
        HAVE_BROKEN_PIPE_BUF = "0"
        HAVE_BROKEN_POLL = "0"
        HAVE_BROKEN_POSIX_SEMAPHORES = "0"
        HAVE_BROKEN_PTHREAD_SIGMASK = "0"
        HAVE_BROKEN_SEM_GETVALUE = "1"
        HAVE_BROKEN_UNSETENV = "0"
        HAVE_C99_BOOL = "1"
        HAVE_CHFLAGS = "1"
        HAVE_CHOWN = "1"
        HAVE_CHROOT = "1"
        HAVE_CLOCK = "1"
        HAVE_COMPUTED_GOTOS = "1"
        HAVE_CONFSTR = "1"
        HAVE_CONIO_H = "0"
        HAVE_COPYSIGN = "1"
        HAVE_CTERMID = "1"
        HAVE_CTERMID_R = "1"
        HAVE_CURSES_H = "1"
        HAVE_CURSES_IS_TERM_RESIZED = "1"
        HAVE_CURSES_RESIZETERM = "1"
        HAVE_CURSES_RESIZE_TERM = "1"
        HAVE_DECL_ISFINITE = "1"
        HAVE_DECL_ISINF = "1"
        HAVE_DECL_ISNAN = "1"
        HAVE_DECL_TZNAME = "0"
        HAVE_DEVICE_MACROS = "1"
        HAVE_DEV_PTC = "0"
        HAVE_DEV_PTMX = "1"
        HAVE_DIRECT_H = "0"
        HAVE_DIRENT_H = "1"
        HAVE_DLFCN_H = "1"
        HAVE_DLOPEN = "1"
        HAVE_DUP2 = "1"
        HAVE_DYNAMIC_LOADING = "1"
        HAVE_EPOLL = "0"
        HAVE_ERF = "1"
        HAVE_ERFC = "1"
        HAVE_ERRNO_H = "1"
        HAVE_EXECV = "1"
        HAVE_EXPM1 = "1"
        HAVE_FCHDIR = "1"
        HAVE_FCHMOD = "1"
        HAVE_FCHOWN = "1"
        HAVE_FCNTL_H = "1"
        HAVE_FDATASYNC = "0"
        HAVE_FINITE = "1"
        HAVE_FLOCK = "1"
        HAVE_FORK = "1"
        HAVE_FORKPTY = "1"
        HAVE_FPATHCONF = "1"
        HAVE_FSEEK64 = "0"
        HAVE_FSEEKO = "1"
        HAVE_FSTATVFS = "1"
        HAVE_FSYNC = "1"
        HAVE_FTELL64 = "0"
        HAVE_FTELLO = "1"
        HAVE_FTIME = "1"
        HAVE_FTRUNCATE = "1"
        HAVE_GAI_STRERROR = "1"
        HAVE_GAMMA = "1"
        HAVE_GCC_ASM_FOR_X87 = "1"
        HAVE_GETADDRINFO = "1"
        HAVE_GETCWD = "1"
        HAVE_GETC_UNLOCKED = "1"
        HAVE_GETENTROPY = "0"
        HAVE_GETGROUPS = "1"
        HAVE_GETHOSTBYNAME = "1"
        HAVE_GETHOSTBYNAME_R = "0"
        HAVE_GETHOSTBYNAME_R_3_ARG = "0"
        HAVE_GETHOSTBYNAME_R_5_ARG = "0"
        HAVE_GETHOSTBYNAME_R_6_ARG = "0"
        HAVE_GETITIMER = "1"
        HAVE_GETLOADAVG = "1"
        HAVE_GETLOGIN = "1"
        HAVE_GETNAMEINFO = "1"
        HAVE_GETPAGESIZE = "1"
        HAVE_GETPEERNAME = "1"
        HAVE_GETPGID = "1"
        HAVE_GETPGRP = "1"
        HAVE_GETPID = "1"
        HAVE_GETPRIORITY = "1"
        HAVE_GETPWENT = "1"
        HAVE_GETRESGID = "0"
        HAVE_GETRESUID = "0"
        HAVE_GETSID = "1"
        HAVE_GETSPENT = "0"
        HAVE_GETSPNAM = "0"
        HAVE_GETTIMEOFDAY = "1"
        HAVE_GETWD = "1"
        HAVE_GRP_H = "1"
        HAVE_HSTRERROR = "1"
        HAVE_HYPOT = "1"
        HAVE_IEEEFP_H = "0"
        HAVE_INET_ATON = "1"
        HAVE_INET_PTON = "1"
        HAVE_INITGROUPS = "1"
        HAVE_INT32_T = "1"
        HAVE_INT64_T = "1"
        HAVE_INTTYPES_H = "1"
        HAVE_IO_H = "0"
        HAVE_KILL = "1"
        HAVE_KILLPG = "1"
        HAVE_KQUEUE = "1"
        HAVE_LANGINFO_H = "1"
        HAVE_LARGEFILE_SUPPORT = "0"
        HAVE_LCHFLAGS = "1"
        HAVE_LCHMOD = "1"
        HAVE_LCHOWN = "1"
        HAVE_LGAMMA = "1"
        HAVE_LIBDL = "1"
        HAVE_LIBDLD = "0"
        HAVE_LIBIEEE = "0"
        HAVE_LIBINTL_H = "0"
        HAVE_LIBREADLINE = "1"
        HAVE_LIBRESOLV = "0"
        HAVE_LIBUTIL_H = "0"
        HAVE_LINK = "1"
        HAVE_LINUX_NETLINK_H = "0"
        HAVE_LINUX_TIPC_H = "0"
        HAVE_LOG1P = "1"
        HAVE_LONG_DOUBLE = "1"
        HAVE_LONG_LONG = "1"
        HAVE_LSTAT = "1"
        HAVE_MAKEDEV = "1"
        HAVE_MEMMOVE = "1"
        HAVE_MEMORY_H = "1"
        HAVE_MKFIFO = "1"
        HAVE_MKNOD = "1"
        HAVE_MKTIME = "1"
        HAVE_MMAP = "1"
        HAVE_MREMAP = "0"
        HAVE_NCURSES_H = "1"
        HAVE_NDIR_H = "0"
        HAVE_NETPACKET_PACKET_H = "0"
        HAVE_NICE = "1"
        HAVE_OPENPTY = "1"
        HAVE_OSX105_SDK = "1"
        HAVE_PATHCONF = "1"
        HAVE_PAUSE = "1"
        HAVE_PLOCK = "0"
        HAVE_PROCESS_H = "0"
        HAVE_PROTOTYPES = "1"
        HAVE_PTH = "0"
        HAVE_PTHREAD_ATFORK = "1"
        HAVE_PTHREAD_DESTRUCTOR = "0"
        HAVE_PTHREAD_H = "1"
        HAVE_PTHREAD_INIT = "0"
        HAVE_PTHREAD_SIGMASK = "1"
        HAVE_PTY_H = "0"
        HAVE_PUTENV = "1"
        HAVE_READLINK = "1"
        HAVE_REALPATH = "1"
        HAVE_RL_CALLBACK = "1"
        HAVE_RL_CATCH_SIGNAL = "1"
        HAVE_RL_COMPLETION_APPEND_CHARACTER = "1"
        HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK = "1"
        HAVE_RL_COMPLETION_MATCHES = "1"
        HAVE_RL_COMPLETION_SUPPRESS_APPEND = "1"
        HAVE_RL_PRE_INPUT_HOOK = "1"
        HAVE_RL_RESIZE_TERMINAL = "1"
        HAVE_ROUND = "1"
        HAVE_SELECT = "1"
        HAVE_SEM_GETVALUE = "1"
        HAVE_SEM_OPEN = "1"
        HAVE_SEM_TIMEDWAIT = "0"
        HAVE_SEM_UNLINK = "1"
        HAVE_SETEGID = "1"
        HAVE_SETEUID = "1"
        HAVE_SETGID = "1"
        HAVE_SETGROUPS = "1"
        HAVE_SETITIMER = "1"
        HAVE_SETLOCALE = "1"
        HAVE_SETPGID = "1"
        HAVE_SETPGRP = "1"
        HAVE_SETREGID = "1"
        HAVE_SETRESGID = "0"
        HAVE_SETRESUID = "0"
        HAVE_SETREUID = "1"
        HAVE_SETSID = "1"
        HAVE_SETUID = "1"
        HAVE_SETVBUF = "1"
        HAVE_SHADOW_H = "0"
        HAVE_SIGACTION = "1"
        HAVE_SIGINTERRUPT = "1"
        HAVE_SIGNAL_H = "1"
        HAVE_SIGRELSE = "1"
        HAVE_SNPRINTF = "1"
        HAVE_SOCKADDR_SA_LEN = "1"
        HAVE_SOCKADDR_STORAGE = "1"
        HAVE_SOCKETPAIR = "1"
        HAVE_SPAWN_H = "1"
        HAVE_SSIZE_T = "1"
        HAVE_STATVFS = "1"
        HAVE_STAT_TV_NSEC = "0"
        HAVE_STAT_TV_NSEC2 = "1"
        HAVE_STDARG_PROTOTYPES = "1"
        HAVE_STDINT_H = "1"
        HAVE_STDLIB_H = "1"
        HAVE_STRDUP = "1"
        HAVE_STRFTIME = "1"
        HAVE_STRINGS_H = "1"
        HAVE_STRING_H = "1"
        HAVE_STROPTS_H = "0"
        HAVE_STRUCT_STAT_ST_BIRTHTIME = "1"
        HAVE_STRUCT_STAT_ST_BLKSIZE = "1"
        HAVE_STRUCT_STAT_ST_BLOCKS = "1"
        HAVE_STRUCT_STAT_ST_FLAGS = "1"
        HAVE_STRUCT_STAT_ST_GEN = "1"
        HAVE_STRUCT_STAT_ST_RDEV = "1"
        HAVE_STRUCT_TM_TM_ZONE = "1"
        HAVE_SYMLINK = "1"
        HAVE_SYSCONF = "1"
        HAVE_SYSEXITS_H = "1"
        HAVE_SYS_AUDIOIO_H = "0"
        HAVE_SYS_BSDTTY_H = "0"
        HAVE_SYS_DIR_H = "0"
        HAVE_SYS_EPOLL_H = "0"
        HAVE_SYS_EVENT_H = "1"
        HAVE_SYS_FILE_H = "1"
        HAVE_SYS_LOADAVG_H = "0"
        HAVE_SYS_LOCK_H = "1"
        HAVE_SYS_MKDEV_H = "0"
        HAVE_SYS_MODEM_H = "0"
        HAVE_SYS_NDIR_H = "0"
        HAVE_SYS_PARAM_H = "1"
        HAVE_SYS_POLL_H = "1"
        HAVE_SYS_RESOURCE_H = "1"
        HAVE_SYS_SELECT_H = "1"
        HAVE_SYS_SOCKET_H = "1"
        HAVE_SYS_STATVFS_H = "1"
        HAVE_SYS_STAT_H = "1"
        HAVE_SYS_TERMIO_H = "0"
        HAVE_SYS_TIMES_H = "1"
        HAVE_SYS_TIME_H = "1"
        HAVE_SYS_TYPES_H = "1"
        HAVE_SYS_UN_H = "1"
        HAVE_SYS_UTSNAME_H = "1"
        HAVE_SYS_WAIT_H = "1"
        HAVE_TCGETPGRP = "1"
        HAVE_TCSETPGRP = "1"
        HAVE_TEMPNAM = "1"
        HAVE_TERMIOS_H = "1"
        HAVE_TERM_H = "1"
        HAVE_TGAMMA = "1"
        HAVE_THREAD_H = "0"
        HAVE_TIMEGM = "1"
        HAVE_TIMES = "1"
        HAVE_TMPFILE = "1"
        HAVE_TMPNAM = "1"
        HAVE_TMPNAM_R = "0"
        HAVE_TM_ZONE = "1"
        HAVE_TRUNCATE = "1"
        HAVE_TZNAME = "0"
        HAVE_UCS4_TCL = "0"
        HAVE_UINT32_T = "1"
        HAVE_UINT64_T = "1"
        HAVE_UINTPTR_T = "1"
        HAVE_UNAME = "1"
        HAVE_UNISTD_H = "1"
        HAVE_UNSETENV = "1"
        HAVE_USABLE_WCHAR_T = "0"
        HAVE_UTIL_H = "1"
        HAVE_UTIMES = "1"
        HAVE_UTIME_H = "1"
        HAVE_WAIT3 = "1"
        HAVE_WAIT4 = "1"
        HAVE_WAITPID = "1"
        HAVE_WCHAR_H = "1"
        HAVE_WCSCOLL = "1"
        HAVE_WORKING_TZSET = "1"
        HAVE_ZLIB_COPY = "1"
        HAVE__GETPTY = "0"
        HGBRANCH = ""
        HGTAG = ""
        HGVERSION = ""
        HOST_GNU_TYPE = "x86_64-apple-darwin15.6.0"
        HURD_C_THREADS = "0"
        INCLDIRSTOMAKE = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7 /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7"
        INCLUDEDIR = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include"
        INCLUDEPY = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/include/python2.7"
        INSTALL = "/usr/bin/install -c"
        INSTALL_DATA = "/usr/bin/install -c -m 644"
        INSTALL_PROGRAM = "/usr/bin/install -c"
        INSTALL_SCRIPT = "/usr/bin/install -c"
        INSTALL_SHARED = "/usr/bin/install -c -m 555"
        INSTSONAME = "Python.framework/Versions/2.7/Python"
        LDCXXSHARED = "clang++ -bundle -undefined dynamic_lookup"
        LDFLAGS = ""
        LDLAST = ""
        LDLIBRARY = "Python.framework/Versions/2.7/Python"
        LDLIBRARYDIR = ""
        LDSHARED = "clang -bundle -undefined dynamic_lookup"
        LIBC = ""
        LIBDEST = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7"
        LIBDIR = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib"
        LIBFFI_INCLUDEDIR = ""
        LIBM = ""
        LIBOBJDIR = "Python/"
        LIBOBJS = ""
        LIBP = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7"
        LIBPC = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig"
        LIBPL = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config"
        LIBRARY = "libpython2.7.a"
        LIBRARY_OBJS = "\"
        LIBS = "-ldl  -framework CoreFoundation"
        LIBSUBDIRS = "lib-tk lib-tk/test lib-tk/test/test_tkinter \"
        LINKCC = "clang"
        LINKFORSHARED = "-u _PyMac_Error /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python"
        LLVM_PROF_ERR = "no"
        LLVM_PROF_FILE = "LLVM_PROFILE_FILE="code-%p.profclangr""
        LLVM_PROF_MERGER = "/usr/bin/xcrun llvm-profdata merge -output=code.profclangd *.profclangr"
        LN = "ln"
        LOCALMODLIBS = ""
        MACHDEP = "darwin"
        MACHDEPPATH = ":plat-darwin"
        MACHDEPS = "plat-darwin plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \"
        MACHDEP_OBJS = "Python/mactoolboxglue.o"
        MACHDESTLIB = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7"
        MACH_C_THREADS = "0"
        MACOSX_DEPLOYMENT_TARGET = "10.11"
        MAINCC = "clang"
        MAJOR_IN_MKDEV = "0"
        MAJOR_IN_SYSMACROS = "0"
        MAKESETUP = "./Modules/makesetup"
        MANDIR = "/usr/local/opt/python/share/man"
        MEMTESTOPTS = "-l -x test_subprocess test_io test_lib2to3 \ -x test_dl test___all__ test_fork1 \"
        MKDIR_P = "./install-sh -c -d"
        MODLIBS = ""
        MODOBJS = "Modules/threadmodule.o  Modules/signalmodule.o  Modules/posixmodule.oModules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/_weakref.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/xxsubtype.o"
        MODULE_OBJS = "\"
        MULTIARCH = ""
        MVWDELCH_IS_EXPRESSION = "1"
        OBJECT_OBJS = "\"
        OLDPATH = ":lib-old"
        OPCODETARGETGEN = "\"
        OPCODETARGETGEN_FILES = "\"
        OPCODETARGETS_H = "\"
        OPT = "-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes"
        OTHER_LIBTOOL_OPT = ""
        PACKAGE_BUGREPORT = "0"
        PACKAGE_NAME = "0"
        PACKAGE_STRING = "0"
        PACKAGE_TARNAME = "0"
        PACKAGE_URL = "0"
        PACKAGE_VERSION = "0"
        PARSER_HEADERS = "\"
        PARSER_OBJS = "\ Parser/myreadline.o Parser/tokenizer.o"
        PGEN = "Parser/pgen"
        PGENOBJS = "\ \"
        PGENSRCS = "\ \"
        PGOBJS = "\"
        PGO_PROF_GEN_FLAG = "-fprofile-instr-generate"
        PGO_PROF_USE_FLAG = "-fprofile-instr-use=code.profclangd"
        PGSRCS = "\"
        PLATDIR = "plat-darwin"
        PLATMACDIRS = "plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \"
        PLATMACPATH = ":plat-mac:plat-mac/lib-scriptpackages"
        POBJS = "\"
        POSIX_SEMAPHORES_NOT_ENABLED = "0"
        PROFILE_TASK = "-m test.regrtest --pgo -x test_asyncore test_gdb test_multiprocessing test_subprocess"
        PSRCS = "\"
        PTHREAD_SYSTEM_SCHED_SUPPORTED = "1"
        PURIFY = ""
        PYLONG_BITS_IN_DIGIT = "0"
        PYTHON = "python"
        PYTHONFRAMEWORK = "Python"
        PYTHONFRAMEWORKDIR = "Python.framework"
        PYTHONFRAMEWORKINSTALLDIR = "/usr/local/opt/python/Frameworks/Python.framework"
        PYTHONFRAMEWORKPREFIX = "/usr/local/opt/python/Frameworks"
        PYTHONPATH = ":plat-darwin:plat-mac:plat-mac/lib-scriptpackages:lib-tk:lib-old"
        PYTHON_FOR_BUILD = "./python.exe -E"
        PYTHON_HEADERS = "\"
        PYTHON_OBJS = "\"
        PY_CFLAGS = "-fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv-O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include  -DPy_BUILD_CORE"
        PY_FORMAT_LONG_LONG = ""ll""
        PY_FORMAT_SIZE_T = ""z""
        PY_UNICODE_TYPE = "unsigned short"
        Py_DEBUG = "0"
        Py_ENABLE_SHARED = "0"
        Py_UNICODE_SIZE = "2"
        Py_USING_UNICODE = "1"
        QUICKTESTOPTS = "-l -x test_subprocess test_io test_lib2to3 \"
        RANLIB = "ranlib"
        RESSRCDIR = "Mac/Resources/framework"
        RETSIGTYPE = "void"
        RUNSHARED = "DYLD_FRAMEWORK_PATH=/private/tmp/python-20170404-12873-188zj3c/Python-2.7.13"
        SCRIPTDIR = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib"
        SETPGRP_HAVE_ARG = "0"
        SGI_ABI = ""
        SHELL = "/bin/sh"
        SHLIBS = "-ldl  -framework CoreFoundation"
        SHLIB_EXT = "".so""
        SIGNAL_OBJS = ""
        SIGNED_RIGHT_SHIFT_ZERO_FILLS = "0"
        SITEPATH = ""
        SIZEOF_DOUBLE = "8"
        SIZEOF_FLOAT = "4"
        SIZEOF_FPOS_T = "8"
        SIZEOF_INT = "4"
        SIZEOF_LONG = "8"
        SIZEOF_LONG_DOUBLE = "16"
        SIZEOF_LONG_LONG = "8"
        SIZEOF_OFF_T = "8"
        SIZEOF_PID_T = "4"
        SIZEOF_PTHREAD_T = "8"
        SIZEOF_SHORT = "2"
        SIZEOF_SIZE_T = "8"
        SIZEOF_TIME_T = "8"
        SIZEOF_UINTPTR_T = "8"
        SIZEOF_VOID_P = "8"
        SIZEOF_WCHAR_T = "4"
        SIZEOF__BOOL = "1"
        SO = ".so"
        SRCDIRS = "Parser Grammar Objects Python Modules Mac"
        SRC_GDB_HOOKS = "./Tools/gdb/libpython.py"
        STDC_HEADERS = "1"
        STRICT_SYSV_CURSES = "/* Don't use ncurses extensions */"
        STRINGLIB_HEADERS = "\"
        SUBDIRS = ""
        SUBDIRSTOO = "Include Lib Misc Demo"
        SVNVERSION = "svnversion ."
        SYSLIBS = ""
        SYS_SELECT_WITH_SYS_TIME = "1"
        TANH_PRESERVES_ZERO_SIGN = "1"
        TCLTK_INCLUDES = ""
        TCLTK_LIBS = ""
        TESTOPTS = "-l"
        TESTPATH = ""
        TESTPROG = "./Lib/test/regrtest.py"
        TESTPYTHON = "DYLD_FRAMEWORK_PATH=/private/tmp/python-20170404-12873-188zj3c/Python-2.7.13 ./python.exe -Wd -3 -E -tt"
        TESTPYTHONOPTS = ""
        THREADOBJ = "Python/thread.o"
        TIME_WITH_SYS_TIME = "1"
        TKPATH = ":lib-tk"
        TM_IN_SYS_TIME = "0"
        UNICODE_OBJS = "Objects/unicodeobject.o Objects/unicodectype.o"
        UNIVERSALSDK = ""
        USE_COMPUTED_GOTOS = "0"
        USE_TOOLBOX_OBJECT_GLUE = "1"
        VA_LIST_IS_ARRAY = "1"
        VERSION = "2.7"
        WANT_SIGFPE_HANDLER = "0"
        WANT_WCTYPE_FUNCTIONS = "0"
        WINDOW_HAS_FLAGS = "0"
        WITH_DOC_STRINGS = "1"
        WITH_DYLD = "1"
        WITH_LIBINTL = "0"
        WITH_NEXT_FRAMEWORK = "1"
        WITH_PYMALLOC = "1"
        WITH_THREAD = "1"
        WITH_TSC = "0"
        WITH_VALGRIND = "0"
        X87_DOUBLE_ROUNDING = "0"
        XMLLIBSUBDIRS = "xml xml/dom xml/etree xml/parsers xml/sax"
        abs_builddir = "/private/tmp/python-20170404-12873-188zj3c/Python-2.7.13"
        abs_srcdir = "/private/tmp/python-20170404-12873-188zj3c/Python-2.7.13"
        base = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7"
        build = "x86_64-apple-darwin15.6.0"
        datarootdir = "/usr/local/opt/python/share"
        exec_prefix = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7"
        host = "x86_64-apple-darwin15.6.0"
        platbase = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7"
        prefix = "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7"
        projectbase = "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin"
        py_version = "2.7.13"
        py_version_nodot = "27"
        py_version_short = "2.7"
        srcdir = "."
        userbase = "/Users/kankyuu/Library/Python/2.7"

BTW, my PC is MacOS 10.11.6. And I installed mycli with Homebrew 1.2.0

meeuw commented 7 years ago

I've compared this output to the homebrew install of @tsroten but I don't see much differences for the unicode related configuration. (Except @tsroten is running Sierra, but I don't think that would make a difference). Python 2.7 is supported but maybe you could try to use Python 3 for mycli, Python 3 is much better at unicode.

goshan commented 7 years ago

so I install python3 with Homebrew, right?. could you tell me how could I set mycli to use python3. It may be using python 2.7.13 by default.

meeuw commented 7 years ago

I don't have much experience with homebrew, You could use a python 3 virtualenv, then you're sure python3 is used. You can use the following commands:

$ pip3.5 install virtualenv
$ virtualenv-3.5 mycli
$ . mycli/bin/activate
$ pip install mycli
$ mycli
tsroten commented 7 years ago

I don't think the command is virtualenv-3.5 mycli (at least that doesn't work on my computer), instead for the second command, you could do virtualenv -p python3.5 mycli

goshan commented 7 years ago

@meeuw @tsroten I got it! FinalIy, I installed python3.6 with Homebrew, and install mycli using what you told me. And now I could output utf8 normally. Thank you guys very much!

cangyin commented 4 years ago

How do I get MyCli run with utf-8 support on Windows?

Although we don't currently have that as a command line option you can still specify that in the ~/.my.cnf file as follows:

[client] default-character-set=utf8 It will be honored by mycli.

I put my.ini in %USERPROFILE%\ (with default-character-set=utf8) . Restarted mysql service and MyCli, but still results as following: image

What did I do wrong?