D:\mysql-5.6.24-win32\bin\mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 55
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> lsb_release -a
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'lsb_r
elease -a' at line 1
mysql> show variables like'%char%'
-> ;
+--------------------------+---------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | D:\mysql-5.6.24-win32\share\charsets\ |
+--------------------------+---------------------------------------+
8 rows in set (0.00 sec)
mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'datab
ase' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hibernate |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.17 sec)
mysql> create database test2;
Query OK, 1 row affected (0.40 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hibernate |
| mysql |
| performance_schema |
| test |
| test2 |
+--------------------+
6 rows in set (0.00 sec)
mysql> show create database test2;
+----------+------------------------------------------------------------------+
| Database | Create Database |
+----------+------------------------------------------------------------------+
| test2 | CREATE DATABASE `test2` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> set character_set_database=utf8;
Query OK, 0 rows affected (0.07 sec)
mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> create database test3;
Query OK, 1 row affected (0.13 sec)
mysql> show create database test3;
+----------+----------------------------------------------------------------+
| Database | Create Database |
+----------+----------------------------------------------------------------+
| test3 | CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+----------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show variables like'%char%';
+--------------------------+---------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | D:\mysql-5.6.24-win32\share\charsets\ |
+--------------------------+---------------------------------------+
8 rows in set (0.00 sec)
mysql> use test3;
Database changed
mysql> create table student(id int,name varchar(50));
Query OK, 0 rows affected (1.42 sec)
mysql> show create table student;
+---------+---------------------------------------------------------------------
---------------------------------------------------------+
| Table | Create Table
|
+---------+---------------------------------------------------------------------
---------------------------------------------------------+
| student | CREATE TABLE `student` (
`id` int(11) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+---------+---------------------------------------------------------------------
---------------------------------------------------------+
1 row in set (0.15 sec)
mysql> use test2;
Database changed
mysql> create table student(id int,name varchar(50));
Query OK, 0 rows affected (0.60 sec)
mysql> show create table student;
+---------+---------------------------------------------------------------------
-----------------------------------------------------------+
| Table | Create Table
|
+---------+---------------------------------------------------------------------
-----------------------------------------------------------+
| student | CREATE TABLE `student` (
`id` int(11) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+---------+---------------------------------------------------------------------
-----------------------------------------------------------+
1 row in set (0.02 sec)
mysql> insert into student values(1,'小明');
Query OK, 1 row affected, 1 warning (0.11 sec)
mysql> select * from student;
+------+------+
| id | name |
+------+------+
| 1 | ?? |
+------+------+
1 row in set (0.00 sec)
mysql> use test3;
Database changed
mysql> insert into student values(1,'小明');
Query OK, 1 row affected (0.05 sec)
mysql> select * from student;
+------+------+
| id | name |
+------+------+
| 1 | 小明 |
+------+------+
1 row in set (0.00 sec)
mysql>
标签:set,utf8,character,sec,student,mysql,row
From: https://blog.51cto.com/gjwrxz/6322261