2017-02-24 86 views
0

我必須設置一個MySQL,它運行在只讀介質上,如DVD等。 基於來自MySql https://dev.mysql.com/doc/refman/5.7/en/innodb-read-only-instance.html的文檔,似乎並不困難。ReadOnlyMedia上的MySQL 5.7

但是,如果描述了配置,則無法從ISO文件啓動服務器。

我的參數來啓動服務器:

mysql-5.7.17-win32\bin\mysqld.exe --no-defaults --console --port=3307 --innodb-read-only=1 --event-scheduler=disabled --innodb_change_buffering=none --innodb_flush_method=normal --pid-file=d:\mysql.pid 

可惜,這是行不通的。 我會得到日誌:

2017-02-24T18:23:33.913117Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
2017-02-24T18:23:33.913117Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 
2017-02-24T18:23:33.914120Z 0 [Note] mysql-5.7.17-win32\bin\mysqld.exe (mysqld 5.7.17) starting as process 9468 ... 
2017-02-24T18:23:33.916995Z 0 [Warning] Can't create test file G:\mysql-5.7.17-win32\data\MyComputer.lower-test 
2017-02-24T18:23:33.917497Z 0 [Warning] Can't create test file G:\mysql-5.7.17-win32\data\MyComputer.lower-test 
2017-02-24T18:23:33.919531Z 0 [Note] InnoDB: Started in read only mode 
2017-02-24T18:23:33.919531Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions 
2017-02-24T18:23:33.920004Z 0 [Note] InnoDB: Uses event mutexes 
2017-02-24T18:23:33.920004Z 0 [Note] InnoDB: Memory barrier is not used 
2017-02-24T18:23:33.920004Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 
2017-02-24T18:23:33.920504Z 0 [Note] InnoDB: Number of pools: 1 
2017-02-24T18:23:33.921007Z 0 [Note] InnoDB: Not using CPU crc32 instructions 
2017-02-24T18:23:33.921007Z 0 [Note] InnoDB: Disabling background log and ibuf IO write threads. 
2017-02-24T18:23:33.923041Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 
2017-02-24T18:23:33.928551Z 0 [Note] InnoDB: Completed initialization of buffer pool 
2017-02-24T18:23:33.951319Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 
2017-02-24T18:23:34.109640Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 
2017-02-24T18:23:34.110647Z 0 [ERROR] InnoDB: Operating system error number 5 in a file operation. 
2017-02-24T18:23:34.110647Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. It may also be you have created a subdirectory of the same name as a data file. 
2017-02-24T18:23:34.110647Z 0 [ERROR] InnoDB: Cannot open datafile '.\ibtmp1' 
2017-02-24T18:23:34.110647Z 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary 
2017-02-24T18:23:34.110647Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Cannot open a file 
2017-02-24T18:23:34.414731Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 
2017-02-24T18:23:34.414731Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
2017-02-24T18:23:34.415619Z 0 [ERROR] Failed to initialize plugins. 
2017-02-24T18:23:34.415619Z 0 [ERROR] Aborting 

2017-02-24T18:23:34.416141Z 0 [Note] Binlog end 
2017-02-24T18:23:34.416141Z 0 [Note] Shutting down plugin 'CSV' 
2017-02-24T18:23:34.416640Z 0 [Note] mysql-5.7.17-win32\bin\mysqld.exe: Shutdown complete 

這是正確的,因爲共享表無法創建。我們在只讀媒體上。

但是,我該如何避免創建共享表空間,或者讓它在可讀介質上的臨時文件夾中創建?

+0

SQLite的似乎是這樣一個更好的方法。 – ceejayoz

+0

不幸的是SQLite不是一個選項。 –

回答

0
  • 首先,你需要在一個可寫的媒體創建實例,

  • 做一個關機慢作爲參考文件中描述,

  • 複製/刻錄或任何你的數據庫文件您的「不可寫」 媒體

  • 更改配置參數以反映新配置:datadir,innodb_data_home_dir,....

  • 重新啓動您的實例

等瞧

+0

這就是我做到這一點的方式。問題是ibtmp1文件是在只讀的數據目錄中創建的。我已經找到參數innodb_temp_data_file_path來重命名這個文件,但是我不能在temp目錄中設置一個路徑。它始終是數據目錄的子目錄,它仍然是隻讀的。 –