安裝mysql-5.7.12-winx64

來源:互聯網
上載者:User

標籤:

之前安裝mysql時未做總結,換新電腦,補上安裝記錄,安裝的時候,找了些網友的安裝記錄,發現好多坑

1、mysql-5.7.12-winx64.zip下載

官方:http://dev.mysql.com/downloads/mysql/

2.解壓到C:\job\mysql-5.7.12-winx64

 

3.在C:\job\mysql-5.7.12-winx64下建立my.ini設定檔

內容如下:

####################設定檔開始################### # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [client] default-character-set=utf8  [mysqld] port=3306 basedir  ="C:\job\mysql-5.7.12-winx64/" datadir  ="C:\job\mysql-5.7.12-winx64/data/" tmpdir   ="C:\job\mysql-5.7.12-winx64/data/" socket   ="C:\job\mysql-5.7.12-winx64/data/mysql.sock" log-error="C:\job\mysql-5.7.12-winx64/data/mysql_error.log"  #server_id = 2 #skip-locking  max_connections=100 table_open_cache=256 query_cache_size=1M  tmp_table_size=32M thread_cache_size=8  innodb_data_home_dir="C:\job\mysql-5.7.12-winx64/data/" innodb_flush_log_at_trx_commit =1 innodb_log_buffer_size=128M innodb_buffer_pool_size=128M innodb_log_file_size=10M innodb_thread_concurrency=16 innodb-autoextend-increment=1000 join_buffer_size = 128M sort_buffer_size = 32M read_rnd_buffer_size = 32M max_allowed_packet = 32M explicit_defaults_for_timestamp=true sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

skip-grant-tables #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES####################設定檔結束###################

重點是以下配置,其中datadir的目錄名稱必須是:C:\job\mysql-5.7.12-winx64/data/,加上skip-grant-tables,使root不輸密碼,登陸

4.在windows系統內容變數path,加入如下內容

C:\job\mysql-5.7.12-winx64\bin;(注意加分號)

 

5、將mysql註冊為windows系統服務

具體操作是在命令列中執行以下命令(需要以管理員身份運行命令列):

cd C:\Windows\System32
以管理員身份運行cmd.exe

需要切換到bin目錄,否則,會將服務類別目錄指定為C:\job\mysql-5.7.12-winx64\bin

增加服務命令:mysqld install MySQL --defaults-file="C:\job\mysql-5.7.12-winx64\my.ini" 

移除服務命令為:mysqld remove

6.第5步成功後,初始化data目錄
C:\job\mysql-5.7.12-winx64\bin>mysqld  --initialize

此步驟非常重要,未初始化,可能會導致mysql服務無法啟動(坑一)

7.開啟系統服務管理

可以看到mysql系統服務

在命令列啟動mysql命令為: net start mysql

     關閉mysql命令為:net stop mysql

8、修改root密碼

命令列執行:mysql –uroot

mysql>show databases;

mysql>use mysql;
mysql> update mysql.user set authentication_string=password(‘12345‘) where user=‘root‘ and Host = ‘localhost‘;

mysql> alter user ‘root‘@‘localhost‘ identified by ‘12345‘;

mysql> FLUSH PRIVILEGES;

mysql> QUIT

坑二:新版的mysql資料庫下的user表中已經沒有Password欄位了,而是將加密後的使用者密碼儲存於authentication_string欄位

9、遠程登陸配置

允許root使用者在任何地方進行遠程登入,並具有所有庫任何操作許可權,具體操作如下:

1)在本機先使用root使用者登入mysql:

命令列執行:mysql -u root -p

輸入密碼(第7步中設定的密碼):12345

2)進行授權操作:

mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘12345‘ WITH GRANT OPTION;

重載授權表:

mysql>FLUSH PRIVILEGES;

退出mysql:quit

 

安裝mysql-5.7.12-winx64

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.