---
title: "Linux修改MySql默认存储引擎为InnoDB  "
author: "grzrt"
date: "2012-09-13T18:25:20Z"
tags: []
categories: ["数据库"]
slug: "linux-mysql-innodb"
draft: false
lastmod: "2012-09-13T18:25:20Z"
id: 1678084
url: "https://grzrt.iteye.com/blog/1678084"
---

一、关闭相关应用

二、停止mysql  
bin/mysqladmin -u root -p shutdown

三、备份my.cnf  
cd /etc  
cp my.cnf my.cnf\_bak

四、修改my.cnf  
\[mysqld] 后加入  
vi my.cnf  
default-storage-engine=InnoDB

 

五、删除/mysql/data目录下的ib\_logfile0，ib\_logfile1

否则在启动mysql时会遇到下述错误：  
\[ERROR] Plugin 'InnoDB' init function returned error.  
\[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.  
\[ERROR] Unknown/unsupported table type: InnoDB  
\[ERROR] Aborting

六、启动mysql  
cd /home/administrator/mysql  
bin/mysqld\_safe -user=root &

七、登录mysql检查修改是否成功  
mysql -h ip -u root -p

mysql&gt;show engines;  
mysql&gt;show variables like'storage\_engine';  
+----------------+--------+  
| Variable\_name  | Value  |  
+----------------+--------+  
| storage\_engine | InnoDB |  
+----------------+--------+

 

\--------------------------------------------------------------------------------------------------

 

有时候，我们因为工作的需要会重新配置**MySQL**数据库引擎**innodb**。那么如何在**Linux**系统下重新配置MySQL数据库引擎innodb呢？本文我们就来介绍这一部分内容，接下来就让我们来一起了解一下吧！

1）停止mysql服务。

\[root@mysql ~]# service mysqld  stop。

2）修改mysql的配置文件。

\[root@mysql ~]# vi  /etc/my.cnf。

3）删除datedir文件夹下的包含ib\_logfile1和ibdata的文件。

4）在根目录下建立mysqldata文件夹。

5）启动使设置生效。

my.cnf修改内容如下：

\[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Default to using old password format for compatibility with mysql 3.x

# clients (those using the mysqlclient10 compatibility package).

old\_passwords=1 # Disabling symbolic-links is recommended to prevent assorted security risks;

# to do so, uncomment this line:

# symbolic-links=0 default-storage-engine=InnoDB

set-variable= transaction-isolation=READ-COMMITTED innodb\_data\_home\_dir =

innodb\_data\_file\_path =/mysqldata/ibdata1:2000M;/mysqldata/ibdata2:2000M:autoextend innodb\_buffer\_pool\_size=1G

innodb\_additional\_mem\_pool\_size=20M 

innodb\_log\_file\_size=256M 

innodb\_log\_buffer\_size=8M 

innodb\_flush\_log\_at\_trx\_commit=1 

innodb\_lock\_wait\_timeout=50 

innodb\_thread\_concurrency=5 \[mysqld\_safe]

log-error=/var/log/mysqld.log 

pid-file=/var/run/mysqld/mysqld.pid

\--------------------------------------------------------------------------------------------------

[linux下安装mysql及用户、引擎、连接数、编码等相关设置](http://blog.csdn.net/hxstream/article/details/5143539)

 

Mysql版本：5.1.41

**安装过程：**

 

**1. 安装Server：**

\# rpm -ivh MySQL-server-community-5.1.41-0.rhel5.i386.rpm

安装后路径

数据库目录：/var/lib/mysql/

配置文件：/usr/share/mysql

相关命令：/usr/bin

启动脚本：/etc/rc.d/init.d/

 

**2. 安装Client：**

\# rpm -ivh MySQL-client-community-5.1.41-0.rhel5.i386.rpm

 

**3. 默认会添加自启动程序并启动Mysql，查看Mysql是否已经启动。**

\# netstat -nat

 

**4. 修改root账号密码。**

mysql&gt;update mysql.user set password=PASSWORD('newpassword') where User='root';

 

**5. 增加root账号远程访问权限**

mysql&gt;grant all on \*.* to " Identified by "root123456";

 

**6. 增加非root用户，用户远程访问。**

mysql&gt;grant select,insert,update,delete on mydata.* to test" Identified by "test123456";

 

**7. 修改my.cnf配置文件，修改mysql编码为gbk**

\# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

\# vi /etc/my.cnf

修改下面的内容：

\[client]  
default-character-set=gbk

\[mysqld]  
default-character-set=gbk

\[mysql.server]  
default-character-set=gbk

\[mysqld\_safe]  
default-character-set=gbk

\[mysql]  
default-character-set=gbk