mysql 安裝(window版)
阿新 • • 發佈:2018-12-09
- r官方下載地址:點選開啟連結,解壓並放置到你想要安裝的目錄,以MySQL8.0為例
- 在../MySQL8.0/目錄下新建目錄data和檔案my.ini和內容為: [mysqld] port=3306 basedir=..\MySQL8.0 datadir=..\MySQL8.0\data character_set_server=utf8 sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER default-storage-engine=INNODB explicit_defaults_for_timestamp=true [mysql] default-character-set=utf8 [client] default-character-set=utf8
- 以管理員執行命令列,進入../MySQL8.0/bin資料夾,執行命令mysqld --initialize,該命令需要一段時間,會在data目錄建立一系列檔案。PS:如果出現“Error while setting value 'NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER' to 'sql_mode'”錯誤,在my.ini檔案sql_mode的行首新增“#”註釋掉此引數
- 執行安裝目錄:mysqld --install,啟動服務net start mysql,登入root使用者:mysql -u root -p,輸入臨時密碼:Mfk!j)ajH2uf(在data目錄下的.err檔案,A temporary password is generated for
- 修改預設密碼, alter user [email protected] identified by '新密碼';
- 新建測試使用者、資料庫和表
新建使用者:create user [email protected] identified by 'test';
新建資料庫:create database test;
切換資料庫:use test;
新建表:create table if not exists test(firstname char(20),lastname char(20));
插入資料:insert into test('Michael','Jackson');
常見錯誤:
安裝mysql Install/Remove of the Service Denied!錯誤的解決辦法
解決辦法:
開啟cmd.exe程式的時候選擇“用管理員身份開啟”。