MySQL綠色版安裝整套流程


最近搞黑蘋果。。。所以把所有的系統重新裝了一遍,導致很多環境都是重新部署, 所以整理了之前的一些資料,這篇是關於MySQL綠色版安裝的地方。

一、綠色版安裝

1. 下載MySQL 5.7,地址:http://dev.mysql.com/downloads/mysql/ (選擇32位或者64位版本需根據自身PC情況)

2. 下載后解壓,比如我的目錄結構是:

 

3. 配置Path路徑:系統屬性 => 高級 => 高級 => 系統變量 => path后添加 F:\CSoft\MySQL-5.7\bin

4. 修改my-default.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.

[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 = F:\CSoft\MySQL-5.7
datadir = F:\CSoft\MySQL-5.7\data
port = 3306
# 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 
# !o>UZ!e(h6(m  初始化的密碼

 

5. 系統管理員模式運行cmd 輸入如下命令

C:\Users\LCF>F:          //切換到F目錄
F:\>cd CSoft\MySQL-5.7\bin   //進入bin目錄
F:\CSoft\MySQL-5.7\bin>mysqld --install   //安裝MYSQL服務
Service successfully installed.  //提示服務安裝成功
The current server installed: F:\CSoft\MySQL-5.7\bin\mysqld MySQL

F:\CSoft\MySQL-5.7\bin>mysqld --initialize --console  //根據配置文件初始化,此時會有一大堆消息,
(注意最后的消息:
2016-07-13T14:21:39.268917Z 1 [Note] A temporary password is generated for root@
localhost: !o>UZ!e(h6(m  )
后面這個是密碼待會兒登錄使用的。

F:\CSoft\MySQL-5.7\bin>net start mysql  //啟動mysql服務
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。

F:\CSoft\MySQL-5.7\bin>mysql -uroot -p  //登錄mysql
Enter password: ************   //密碼就是輸入的密碼

mysql> set password=password('123456');     //修改密碼
Query OK, 0 rows affected, 1 warning (0.00 sec)

目前為止成功安裝。

二、中文亂碼修改

1. 從服務端進行修改

show variables like "%char%";  

然后可能顯示如下信息,注意紅色部分,不同的用戶可能實際情況不同,但是需要保證除了 filesystem為binary外,其他都為utf8:

+--------------------------+---------------+  
| Variable_name | Value |  
+--------------------------+---------------+  
| character_set_client | gbk |  
| character_set_connection | gbk |  
| character_set_database | utf8 |  
| character_set_filesystem | binary |  
| character_set_results | gbk |  
| character_set_server | utf8 |  
| character_set_system | utf8 |  
+--------------------------+-------------+  
 

2. 通過如下SQL語句進行修改,全部設置為utf8即可:

#設置數據庫編碼信息
SET character_set_client='utf8';  
SET character_set_connection='utf8';  
SET character_set_database ='utf8';  
SET character_set_results='utf8';  
SET character_set_server='utf8'; 

3、SQL連接字符串加上?useUnicode=true&characterEncoding=utf-8

jdbc.url = jdbc:mysql://localhost:3306/bsframe?useUnicode=true&characterEncoding=utf-8

一般按照上述步驟后,就不會出現亂碼了!

三、修改為任意用戶可以連接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;

 這里的yourpassword 是你設定的密碼,請自行修改。


免責聲明!

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



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