• mysql中文乱码解决


    1.安装mysql中选择数据字符集为utf-8

    2.创建数据库

     create database zhaochao charset utf8;

    3.创建表时

     create table user(id int ,username varchar(60),userpasswd varchar(60)) charset utf8;

    4.插入数据时

     set names gbk;


    
    C:UsersAdministrator>mysql -uroot -padmin
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2 to server version: 5.0.22-community-nt
    Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
    
    mysql> create database zhaochao charset utf8;
    Query OK, 1 row affected (0.00 sec)
    
    mysql> use zhaochao;
    Database changed
    mysql> create table user(id int ,username varchar(60),userpasswd varchar(60)) charset utf8;
    Query OK, 0 rows affected (0.07 sec)
    
    mysql> show variables like '%char%';
    +--------------------------+---------------------------------------------------------+
    | Variable_name            | Value                                                   |
    +--------------------------+---------------------------------------------------------+
    | character_set_client     | utf8                                                    |
    | character_set_connection | utf8                                                    |
    | character_set_database   | utf8                                                    |
    | character_set_filesystem | binary                                                  |
    | character_set_results    | utf8                                                    |
    | character_set_server     | utf8                                                    |
    | character_set_system     | utf8                                                    |
    | character_sets_dir       | C:Program FilesMySQLMySQL Server 5.0sharecharsets |
    +--------------------------+---------------------------------------------------------+
    8 rows in set (0.00 sec)
    
    mysql> insert into user values (1,'赵超','zhaochao');
    ERROR 1406 (22001): Data too long for column 'username' at row 1
    mysql> set names gbk;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> insert into user values (1,'赵超','zhaochao');
    Query OK, 1 row affected (0.02 sec)
    
    mysql> select * from user;
    +------+----------+------------+
    | id   | username | userpasswd |
    +------+----------+------------+
    |    1 | 赵超        | zhaochao   |
    +------+----------+------------+
    1 row in set (0.00 sec)
    
    mysql> select * from user;
    +------+----------+------------+
    | id   | username | userpasswd |
    +------+----------+------------+
    |    1 | 赵超        | zhaochao   |
    |    1 | 赵云         | zhaoyun    |
    +------+----------+------------+
    2 rows in set (0.00 sec)
    
    mysql> select * from user;
    +------+----------+------------+
    | id   | username | userpasswd |
    +------+----------+------------+
    |    1 | 赵超        | zhaochao   |
    |    1 | 赵云         | zhaoyun    |
    |    1 | 赵云         | zhaoyun    |
    +------+----------+------------+
    3 rows in set (0.00 sec)
    



  • 相关阅读:
    申请Namecheap的.me 顶级域名以及申请ssl认证--github教育礼包之namecheap
    Floodlight+Mininet的SDN实验平台搭建初探
    在DigitalOcean vps中安装vnstat监控流量,浏览器打开php代码。。。
    知识积累
    vue路由跳转(新开页面 当前页面)
    手机访问电脑本地静态页面
    Vue:scoped与module的使用与利弊
    小技巧
    布局记录
    vue项目及vuex使用
  • 原文地址:https://www.cnblogs.com/whzhaochao/p/5023486.html
Copyright © 2020-2023  润新知