Win7安裝解壓版MySQL


1.下載MySQL

訪問https://dev.mysql.com/downloads/mysql/5.6.html#downloads,下載操作系統對應的版本(無賬號需先注冊一個),以mysql-5.6.38-win32為例

2.解壓

以解壓到D:\soft_dev\mysql-5.6.38-win32為例

3.修改配置文件

解壓完mysql-5.6.38-win32目錄下有一個配置文件模板my-default.ini,復制一份並命名為my.ini,修改內容如下:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
 basedir = D:/soft_dev/mysql-5.6.38-win32
 datadir = D:/soft_dev/mysql-5.6.38-win32/data
# port = .....
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
 join_buffer_size = 128M
 sort_buffer_size = 2M
 read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

 注意:

  (1)配置文件起作用的兩種方式:創建my.ini、啟動服務時指定defaults-file

  (2)basedir、datadir路徑中要用/分隔符不能用\,負責啟動服務會報配置錯誤導致的1067錯誤

  (3)MySQL5.6.8之前會將配置文件直接放到安裝目錄下,之后的版本在服務啟動過程中會按照一定的目錄優先級搜素my.ini

4.安裝MySQL服務

進入D:\soft_dev\mysql-5.6.38-win32\bin目錄,執行mysqld.exe -install安裝服務(如果360安全衛士有監測,允許本次操作),mysqld.exe -remove移除服務,效果可在windows服務列表中查看

5.啟動服務

任意位置執行net start mysql

此時再查看Windows服務列表MySQL狀態為啟動,且啟動類型為自動

6.遠程登陸用戶設置

進入D:\soft_dev\mysql-5.6.38-win32\bin目錄,執行mysql -uroot,進入mysql,此時為root免密登錄

mysql> use mysql;

mysql> select host,user,password from user;

mysql> update user set password=password('123456') where user='root';

mysql> update user set host='%' where user='root' and host='localhost';

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

mysql> flush privileges;

mysql> exit

7.修改字符集及其他配置信息

(1) 查看字符集

(2) 修改字符集,修改后my.ini文件內容為:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
 basedir = D:/soft_dev/mysql-5.6.38-win32
 datadir = D:/soft_dev/mysql-5.6.38-win32/data
# port = .....
# server_id = .....
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci 
lower_case_table_names=1
max_connections=1000

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
 join_buffer_size = 128M
 sort_buffer_size = 2M
 read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysql]
default-character-set = utf8

 

(3) 重啟MySQL服務

再次查看字符集

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM