mysql基础教程:如何创建mysql数据库
mysql基础教程:如何创建mysql数据库,最简单的创建数据库命令
CREATE DATABASE my_db;
或者是
CREATE DATABASE IF NOT EXISTS my_db;
创建utf8编码的数据库
CREATE DATABASE IF NOT EXISTS my_db default character set utf8 COLLATE utf8_general_ci;
那么在这个数据库下创建的所有数据表的默认字符集都会是utf8了,注意后面这句话 "COLLATE utf8_general_ci",大致意思是在排序时根据utf8变码格式来排序
查看数据库列表
show databases;
使用数据库
use my_db;
查看数据库默认编码
show variables like 'character_set_%' +--------------------------+-------------------------------------------------------+ | Variable_name | Value | +--------------------------+-------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/local/mysql-5.5.28-Linux2.6-i686/share/charsets/ | +--------------------------+-------------------------------------------------------+
可以看到character_set_database是lantin1.
修改数据库编码
alter database my_db character set latin1;
删除数据库
drop database my_db;
或者是
drop database IF EXISTS my_db;
-
标签错误:<!-- #Label#
labelId=20160707140604
moduleId=1
classId=12231768634
orderby=2
fields=url,title,u_info
attribute=
datatypeId=22192428132
recordCount=3
pageSize=
<htmlTemplate><dt><img src="/images/index_26${index}.jpg" width="100" height="62" /><a href="$url" title="${title}">${title}</a><span>${api.left(u_info,60)}</span></dt></htmlTemplate>
-->
- 我要参加技术沙龙