标签:use art tab sed points 账号 就会 yml com
创建数据库是指在数据库空间中划出一块空间用来存储相关的数据,表就是存储在对应的数据库里面。首先来看下查看数据库的命令:show databases。 这个是用来查询数据库空间下所有的数据库,其中information_schedma/mysql/performace_schema是用来存储管理或者用户账号的数据库。目前还没有我们自己建立的数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
+--------------------+
4 rows in set
创建数据库使用create databases.
mysql> create database test;
Query OK, 1 row affected
然后再查询一次:数据库test已经存在了,表示创建成功
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| test |
+--------------------+
5 rows in set
如果想删除的话:使用drop database 数据库名
mysql> drop database test;
Query OK, 0 rows affected
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
+--------------------+
4 rows in set
存储引擎:
存储引擎其实就是如何存储数据、如何为存储的数据建立索引和如何更新、查询数据等技术的实现方法。因为在关系数据库中数据的存储是以表的形式存储的,所以存储引擎也可以称为表类型(即存储和操作此表的类型)。Mysql有四种引擎方式: 1 MyISAM. 2 InnoDB 3 MEMORY 4 MERGE. 从mysql5.5后以后mysql默认使用InnoDB. 可以用show engines查看mysql支持的存储引擎. 如果想美化一点可以用 show engines \G;
mysql> show engines \G
*************************** 1. row ***************************
Engine: FEDERATED
Support: NO
Comment: Federated MySQL storage engine
Transactions: NULL
XA: NULL
Savepoints: NULL
*************************** 2. row ***************************
Engine: MRG_MYISAM
Support: YES
Comment: Collection of identical MyISAM tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 3. row ***************************
Engine: MyISAM
Support: YES
Comment: MyISAM storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 4. row ***************************
Engine: BLACKHOLE
Support: YES
Comment: /dev/null storage engine (anything you write to it disappears)
Transactions: NO
XA: NO
Savepoints: NO
*************************** 5. row ***************************
Engine: CSV
Support: YES
Comment: CSV storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 6. row ***************************
Engine: MEMORY
Support: YES
Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 7. row ***************************
Engine: ARCHIVE
Support: YES
Comment: Archive storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 8. row ***************************
Engine: InnoDB
Support: DEFAULT
Comment: Supports transactions, row-level locking, and foreign keys
Transactions: YES
XA: YES
Savepoints: YES
*************************** 9. row ***************************
Engine: PERFORMANCE_SCHEMA
Support: YES
Comment: Performance Schema
Transactions: NO
XA: NO
Savepoints: NO
9 rows in set (0.00 sec)
Engine参数指的是存储引擎的名称,support参数表明Mysql是否支持该引擎, comment参数值对引擎的评论,Transactions表示是否支持事务引擎。从上面的结果可以看到InnoDB为默认的存储引擎。
还有一个方法可以查询引擎的支持情况。Yes表示支持,No表示不支持,disable表示支持但还没有开启。
mysql> show variables like ‘have%‘;
+----------------------+----------+
| Variable_name | Value |
+----------------------+----------+
| have_compress | YES |
| have_crypt | NO |
| have_csv | YES |
| have_dynamic_loading | YES |
| have_geometry | YES |
| have_innodb | YES |
| have_ndbcluster | NO |
| have_openssl | DISABLED |
| have_partitioning | YES |
| have_profiling | YES |
| have_query_cache | YES |
| have_rtree_keys | YES |
| have_ssl | DISABLED |
| have_symlink | YES |
+----------------------+----------+
在前面show engines \G中可以看到InnoDB为默认支持的引擎。但是这个方法不够直接。用show variables like ‘storage_engine’ 可以查询到默认支持的引擎
mysql> show variables like ‘storage_engine‘;
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
1 row in set
如果想修改默认的存储引擎。可以在存储Mysql data目录下的my.ini中去修改。my.ini的路径是C:\ProgramData\MySQL\MySQL Server 5.5 默认安装情况下
# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 5.5/Data
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
例如像修改默认存储引擎为MyISAM, 可以直接修改default-storage-engine。然后重启服务,这个时候就会生效。
标签:use art tab sed points 账号 就会 yml com
原文地址:http://www.cnblogs.com/zhanghongfeng/p/7222466.html