{"id":6,"date":"2012-09-18T11:21:10","date_gmt":"2012-09-18T11:21:10","guid":{"rendered":"http:\/\/beta.robertprice.co.uk\/robblog\/2012\/09\/utf8_and_mysql_command_line-shtml\/"},"modified":"2012-09-18T11:21:10","modified_gmt":"2012-09-18T11:21:10","slug":"utf8_and_mysql_command_line-shtml","status":"publish","type":"post","link":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/","title":{"rendered":"Utf8 And MySQL Command Line"},"content":{"rendered":"<p>I&#8217;ve been having to use a lot of utf8 recently, and being old school I still use the command line a lot.<\/p>\n<p>One project has been importing a lot of international data into a mysql database.<\/p>\n<p>The database is in utf8, but when I used the command line, non latin1 data was coming back corrupted.<\/p>\n<p>It turned out that the command line doesn&#8217;t automatically detect the character set, so it was printing as if it was latin1. There is a flag that can be passed in called &#8211;default-character-set and this can be set to utf8. Once set, utf8 data is correctly displayed on my terminal.<\/p>\n<p><code>mysql --default-character-set=utf8 testdatabase<\/code><\/p>\n<p>This is also useful when piping in utf8 data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been having to use a lot of utf8 recently, and being old school I still use the command line a lot. One project has been importing a lot of international data into a mysql database. The database is in utf8, but when I used the command line, non latin1 data was coming back corrupted. &hellip; <a href=\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Utf8 And MySQL Command Line&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[42,71],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-dev","tag-mysql","tag-utf8"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Utf8 And MySQL Command Line - Robert Price<\/title>\n<meta name=\"description\" content=\"Using utf8 data when using MySQL on the command line.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Utf8 And MySQL Command Line - Robert Price\" \/>\n<meta property=\"og:description\" content=\"Using utf8 data when using MySQL on the command line.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2012-09-18T11:21:10+00:00\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"Utf8 And MySQL Command Line\",\"datePublished\":\"2012-09-18T11:21:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\"},\"wordCount\":121,\"keywords\":[\"MySQL\",\"utf8\"],\"articleSection\":[\"Dev\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\",\"url\":\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\",\"name\":\"Utf8 And MySQL Command Line - Robert Price\",\"isPartOf\":{\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/#website\"},\"datePublished\":\"2012-09-18T11:21:10+00:00\",\"author\":{\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"description\":\"Using utf8 data when using MySQL on the command line.\",\"breadcrumb\":{\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.robertprice.co.uk\/robblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Utf8 And MySQL Command Line\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/#website\",\"url\":\"http:\/\/www.robertprice.co.uk\/robblog\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Utf8 And MySQL Command Line - Robert Price","description":"Using utf8 data when using MySQL on the command line.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/","og_locale":"en_GB","og_type":"article","og_title":"Utf8 And MySQL Command Line - Robert Price","og_description":"Using utf8 data when using MySQL on the command line.","og_url":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/","og_site_name":"Robert Price","article_published_time":"2012-09-18T11:21:10+00:00","author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/#article","isPartOf":{"@id":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/"},"author":{"name":"rob","@id":"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"Utf8 And MySQL Command Line","datePublished":"2012-09-18T11:21:10+00:00","mainEntityOfPage":{"@id":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/"},"wordCount":121,"keywords":["MySQL","utf8"],"articleSection":["Dev"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/","url":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/","name":"Utf8 And MySQL Command Line - Robert Price","isPartOf":{"@id":"http:\/\/www.robertprice.co.uk\/robblog\/#website"},"datePublished":"2012-09-18T11:21:10+00:00","author":{"@id":"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"description":"Using utf8 data when using MySQL on the command line.","breadcrumb":{"@id":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.robertprice.co.uk\/robblog\/utf8_and_mysql_command_line-shtml\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"Utf8 And MySQL Command Line"}]},{"@type":"WebSite","@id":"http:\/\/www.robertprice.co.uk\/robblog\/#website","url":"http:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"http:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":0,"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}