mysql create database

  • create database  databasename ;
  • CREATE DATABASE databasename DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;     //support Chinese characters
  • CREATE DATABASE databasename DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;        //support Emoji characters

  • show character set;


今天创建数据库的时候报了以下错误:

BLOB/TEXT column ‘driaycontent’ can’t have a default value

是这两种数据格式不能有默认值,好奇就去查了一下,原来这两种数据类型还有些特殊,具体可以自己去百度,看了一下别人的解释是这样的

The use of mysql

The use of mysql ( mysql version:5.6.34 )

  • mysql -uusername -ppassword      //logon mysql           like:mysql -uroot -pmiPG2e8
  • create database databasename;      //create database     like:create database test;
  • show databases;     //view all databases
  • use databasename;     //change to current database     like:use test;
  • drop database databasename;     //delete database     like:drop database test;
  • show tables;     //view all tables in the current database
  • create table tablename (columnname datatype );      //create table    like:create table test(
    id int unsigned not null auto_increment primary key,
    name char(8) not null,
    sex char(4) not null,
    age tinyint unsigned not null,
    tel char(13) null default “-“);
  • drop table tablename ;      //delete table       like:drop table test;
  • alter table oldtablename rename newtablename ;    // rename table    like: alter table test rename test1;
  • desc tablename;        //view table info       like:desc test;
  • show full fields from tablename;    //show table detail
  • truncate table tablename;     //clear all data in the table    like:truncate table test;
  • select * from tablename where …;    //query all data in the table    like:select * from users where userId = ‘1’;
  • insert into tablename (columnname) values (‘value’) where … ;  //insert      like:insert into users (username,password) values (‘Jerry’,’12345678′) where userId =’1′;
  • update tablename set columnname = ‘value’ where … ;     //update     like:update users set username = ‘Jack’ where userId = ‘1’;
  • delete from tablename where … ;       //delete     like:delete from users where userId = ‘1’;

  • select version();     //view mysql version(In the login state)
  • show character set;         //show all character set for mysql
  • exit;      //exit mysql