最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
免安裝原生產(chǎn)環(huán)境的MySQL是什么

這篇文章主要介紹“免安裝原生產(chǎn)環(huán)境的MySQL是什么”,在日常操作中,相信很多人在免安裝原生產(chǎn)環(huán)境的MySQL是什么問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”免安裝原生產(chǎn)環(huán)境的MySQL是什么”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

成都創(chuàng)新互聯(lián)主營(yíng)渭濱網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,手機(jī)APP定制開發(fā),渭濱h5微信平臺(tái)小程序開發(fā)搭建,渭濱網(wǎng)站營(yíng)銷推廣歡迎渭濱等地區(qū)企業(yè)咨詢

就是它:

        com.wix        wix-embedded-mysql        x.y.z        test 

代碼也簡(jiǎn)單,直接定義你需要的版本,數(shù)據(jù)庫(kù)信息,把要初始化的SQL 給它,走起。

MysqldConfig config = aMysqldConfig(v5_6_23) //這里是版本   .withCharset(UTF8)   .withPort(2215)   .withUser("user1", "pwd2")   .withTimeZone("Europe/Vilnius")   .withTimeout(2, TimeUnit.MINUTES)   .withServerVariable("max_connect_errors", 666)   .build();  EmbeddedMysql mysqld = anEmbeddedMysql(config)   .addSchema("aschema", ScriptResolver.classPathScript("db/001_init.sql"))   .start();  //do work  mysqld.stop(); //optional, as there is a shutdown hook

這有啥優(yōu)勢(shì):

  • 測(cè)試可以跑在和生產(chǎn)環(huán)境基本一致的環(huán)境,同樣的版本,同樣的編碼和配置,database/schema/user settings 等等

  • 比安裝一個(gè)更容易,想切換版本,改配置也更輕松;

  • 本地每個(gè)項(xiàng)目可以使用不同的版本,不同的配置,啥都不用擔(dān)心;

  • 對(duì)于MySQL的多個(gè)版本支持 - 5.5, 5.6, 5.7, 8.0;

  • 多種平臺(tái)和環(huán)境都支持。

原理

這背后是怎么實(shí)現(xiàn)的呢?

咱們是「刨根究底」公眾號(hào),一起來看看。

上面代碼配置之后的 start ,到底 start 了啥?

咱們看下面這幾小段代碼:

protected EmbeddedMysql(             final MysqldConfig mysqldConfig,             final DownloadConfig downloadConfig) {         this.config = mysqldConfig;         IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(mysqldConfig, downloadConfig).build();         MysqldStarter mysqldStarter = new MysqldStarter(runtimeConfig);         localRepository.lock();         try {             this.executable = mysqldStarter.prepare(mysqldConfig);         } finally {             localRepository.unlock();         }          try {             executable.start();             getClient(SCHEMA, mysqldConfig.getCharset()).executeCommands(                     format("CREATE USER '%s'@'%%' IDENTIFIED BY '%s';", mysqldConfig.getUsername(), mysqldConfig.getPassword()));         } catch (IOException e) {             throw new RuntimeException(e);         }     }
protected MysqldProcess start(             final Distribution distribution,             final MysqldConfig config,             final IRuntimeConfig runtime) throws IOException {         logger.info("Preparing mysqld for startup");         Setup.apply(config, executable, runtime);         logger.info("Starting MysqldProcess");         return new MysqldProcess(distribution, config, runtime, this);     }

其實(shí)這背后依賴了一個(gè)叫embed.process的開源項(xiàng)目,

免安裝原生產(chǎn)環(huán)境的MySQL是什么

public AbstractProcess(Distribution distribution, T config, IRuntimeConfig runtimeConfig, E executable)       throws IOException {     this.config = config;     this.runtimeConfig = runtimeConfig;     this.executable = executable;     this.distribution = distribution;     // pid file needs to be set before ProcessBuilder is called     this.pidFile = pidFile(this.executable.getFile().executable());      ProcessOutput outputConfig = runtimeConfig.getProcessOutput();      // Refactor me - to much things done in this try/catch     String nextCall="";     try {        nextCall="onBeforeProcess()";        onBeforeProcess(runtimeConfig);        nextCall="newProcessBuilder()";        ProcessBuilder processBuilder = ProcessControl.newProcessBuilder(           runtimeConfig.getCommandLinePostProcessor().process(distribution,               getCommandLine(distribution, config, this.executable.getFile())),           getEnvironment(distribution, config, this.executable.getFile()), true);         nextCall="onBeforeProcessStart()";        onBeforeProcessStart(processBuilder, config, runtimeConfig);        nextCall="start()";        process = ProcessControl.start(config.supportConfig(), processBuilder);        nextCall="writePidFile()";        if (process.getPid() != null) {         writePidFile(pidFile, process.getPid());       }        nextCall="addShutdownHook()";        if (runtimeConfig.isDaemonProcess() && !executable.isRegisteredJobKiller()) {         ProcessControl.addShutdownHook(new JobKiller());         registeredJobKiller = true;       }        nextCall="onAfterProcessStart()";       onAfterProcessStart(process, runtimeConfig);     } catch (IOException iox) {       stop();       throw iox;     }   }

它又操作了什么呢?從名字你也猜到了,它是直接操作進(jìn)程的,實(shí)際在運(yùn)行時(shí),會(huì)下載一個(gè)MySQL,然后通過腳本啟停。

免安裝原生產(chǎn)環(huán)境的MySQL是什么

初次啟動(dòng)的時(shí)候,會(huì)直接下載

免安裝原生產(chǎn)環(huán)境的MySQL是什么

有了這些,在測(cè)試的時(shí)候就可以和生產(chǎn)環(huán)境一樣,啟動(dòng)時(shí)加載初始化SQL腳本,開始你的工作了。

github地址:https://github.com/wix/wix-embedded-mysql

到此,關(guān)于“免安裝原生產(chǎn)環(huán)境的MySQL是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!


分享名稱:免安裝原生產(chǎn)環(huán)境的MySQL是什么
URL鏈接:http://fisionsoft.com.cn/article/jcgiho.html