Linux修改MySql默認存儲引擎爲InnoDB

一、關閉相關應用

二、停止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>show engines;
mysql>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-variabletransaction-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及用戶、引擎、連接數、編碼等相關設置

 

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>update mysql.user set password=PASSWORD('newpassword') where User='root';

 

5. 增加root賬號遠程訪問權限

mysql>grant all on *.* to " Identified by "root123456";

 

6. 增加非root用戶,用戶遠程訪問。

mysql>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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章