root@allenli-U80V:~# mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
root@allenli-U80V:~# service mysql start //启动mysql后才可登录 Starting MySQL * root@allenli-U80V:~# mysql -u root -p .//登录成功 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, 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.
------------------------------------------------------------------------------- 我们说,防微杜渐才好,下次记得一开始就要统一编码格式,像这样. 一、create database db_name default charset=utf8; creaete table tb_name(...)default charset=utf8; 这样在mysql控制台下会看到正常字符 二、mysql load infile数据缺损或者乱码 load data infile '/wamp/www/mydata/t.txt' into table t character set gbk /*这行可以解决字符导入缺损\乱码问题*/ fields terminated by '\t' enclosed by '\"' lines terminated by '\r\n' ignore 1 lines; // character set utf8造成导入字符缺损或者乱码:一堆问号 通过character set gbk可以使得导入操作成功。 三、网页乱码解决 在网页代码中加入语句: mysqli->query("set names gbk")