Mysql change engine (InnoDB, MyISAM) method, innodbmyisam

Source: Internet
Author: User
Tags mysql code

Mysql change engine (InnoDB, MyISAM) method, innodbmyisam

This article describes how to change the mysql engine (InnoDB, MyISAM. The specific implementation method is as follows:

The default mysql database engine is MyISAM, which does not support transactions and Foreign keys. You can also use InnoDB that supports transactions and Foreign keys.

View the supported database engines and default database engines of the current database

Database-supported engines and default database engine code:
Copy codeThe Code is as follows: show engines;

Method 1:Modify the configuration file my. ini

I save the my-small.ini as my. ini, add it on [mysqld], default-storage-engine = InnoDB, restart the service, and change the default engine of the database to InnoDB

Method 2:Specify or modify the table when creating the table

Mysql code:
-- Specify
Copy codeThe Code is as follows: create table mytbl (
Id int primary key,
Name varchar (50)
) Type = MyISAM;
-- Modify the table after the table is created
Copy codeThe Code is as follows: alter table mytbl2 type = InnoDB;
-- View the Modification result (mytest is the name of the database where the table is located)
Copy codeThe Code is as follows: show table status from mytest;
-- Or use
Copy codeThe Code is as follows: show create table table_name

I hope this article will help you design MySQL database programs.


How to set the storage engine in mysql? How can I change INNODB to MYISAM? How can I save databases, tables, and other objects in MYSQL in DOS?

1. How do I set the storage engine in mysql? ------------ The default value is myisam, which is also specified during table creation. For example, create table test (id int) engine = innodb;
2. How can I change INNODB to MYISAM? ------------------ Alter table test engine = myisam;
3. How to save databases, tables, and other objects in MYSQL in DOS? ----------------- Execute create database databasename; create table test (id int) in dos. In this way, the database and table are generated. The corresponding system file is under data in the mysql installation directory, the database name corresponds to a folder. For example, if you create database testdb, you can find the testdb directory under the data Directory. For objects such as tables, you need to check the specific engine. For myisam engine, there will be three files, test. frm, test. myi, test. there are three myd, and innodb only has one test. frm structure files, data and index files are all in the ibdata1 tablespace.
4. How does PHP connect to MYSQL? Do you have to enter the code? Is there any other simple method, such as UI-based setting -----------------. You need to write the connection information and I have found a php connection to mysql online. For details, refer
<? Php
$ Mysql_server_name = 'localhost'; // change it to your mysql database server.
$ Mysql_username = 'root'; // change the username of your mysql database.
$ Mysql_password = '000000'; // change the password of your mysql database.
$ Mysql_database = 'mydb'; // change the name of your mysql database.

$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password, $ mysql_database); // explain down from the beginning of this sentence

$ SQL = 'insert into book (name, pwd) values ("ggg", "ggg ");';
// This is an SQL statement: Insert a record into the book table

Mysql_query ($ SQL );
// Execute the SQL statement

Mysql_select_db ($ mysql_database, $ conn); // select the database where the above table is located (this statement should be executed before the above sentence)

$ Result = mysql_query ($ SQL); // This sentence is completely redundant. It is the same as the one above!

Mysql_close ($ conn); // close the database connection
Echo "Hello! Operation successful! "; // Display prompt information

?>

Mysql database has a table engine changed from MyISAM to Innodb

Alter table 'table _ name' engine = innodb;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.