Mysql 更改默认引擎 [英] Mysql changing default engine

查看:49
本文介绍了Mysql 更改默认引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将mysql引擎改成MYISAM.现在我有 mysql 和 INNODB,但我想将引擎更改为 MYISAM.我该怎么办?

How to change the mysql engine to MYISAM. Now I am having mysql with INNODB but I want to change the engine to MYISAM. What i have to do?

CREATE TABLE `classifieds_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `site_id` int(11) NOT NULL,
  `template_prefix` varchar(200) NOT NULL,
  `name` varchar(200) NOT NULL,
  `slug` varchar(50) NOT NULL,
  `enable_contact_form_upload` tinyint(1) NOT NULL DEFAULT '0',
  `contact_form_upload_max_size` int(11) NOT NULL DEFAULT '1048576',
  `contact_form_upload_file_extensions` varchar(200) NOT NULL DEFAULT 'txt,doc,odf,pdf',
  `images_max_count` int(11) NOT NULL DEFAULT '0',
  `images_max_width` int(11) NOT NULL DEFAULT '1024',
  `images_max_height` int(11) NOT NULL DEFAULT '1024',
  `images_max_size` int(11) NOT NULL DEFAULT '1048576',
  `description` longtext NOT NULL,
  `sortby_fields` varchar(200) NOT NULL,
  `sort_order` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `classifieds_category_6223029` (`site_id`),
  KEY `classifieds_category_56ae2a2a` (`slug`),
  CONSTRAINT `site_id_refs_id_2d06e6c6` FOREIGN KEY (`site_id`) REFERENCES `django_site` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

我试图在这里更改引擎.但我不想改变每张桌子.有没有什么设置可以一般换引擎??

I tried to change the engine here. but I don't want to change the every table. Is any settings is there to change engine commonly??

我也像SET default_storage_engine=MYISAM;一样运行查询但没有反应.

i also run the query like SET default_storage_engine=MYISAM; But no reaction.

推荐答案

更改变量 default_storage_engine 的值对现有表没有影响.它所做的只是在您未在 create table 语句中指定时,使用您在此变量中指定的引擎创建新表.这只是一个默认值.

Changing the value of the variable default_storage_engine has no effect on existing tables. All it does, is to create new tables with the engine you specified in this variable when you don't specify it in your create table statement. It's just a default value.

还要记住,您必须区分 globalsession 变量值.要在创建新表时真正将 MyISAM 设为默认值,而不仅仅是针对当前会话,请执行以下操作:

Also keep in mind, that you have to distinguish between global and session variable values. To really have MyISAM as default whenever you create a new table, and not just for the current session, do it like this:

SET GLOBAL  default_storage_engine=MYISAM;

如果你想在重启服务器后仍然保持这个变量的值,你必须把下面的行放到你的默认文件 my.cnf 部分下的 [mysqld]代码>

If you want to keep the variable to this value even after restarting the server, you have to put follwing line into your default file my.cnf under the section [mysqld]

default_storage_engine = MYISAM

要将当前表转换为 MyISAM,请对每个表执行此操作:

To convert your current tables to MyISAM do this for every table:

ALTER TABLE table_name ENGINE=MyISAM;

但请记住,您的外键约束将不再起作用,因为 MyISAM 不支持它.它不会抱怨,它只会忽略它.所以你最好确定,你知道你在做什么:)

But keep in mind, that you foreign key constraint will not work anymore, as MyISAM doesn't support it. It will not complain, it will just ignore it. So you better be sure, you know what you're doing :)

这篇关于Mysql 更改默认引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆