欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Windows下安裝MySQL 5.7.17壓縮版中遇到的坑

 更新時(shí)間:2017年01月19日 15:05:49   作者:瓜園耕讀  
最近發(fā)現(xiàn)原來(lái)好端端的MySQL突然間不能用了,無(wú)奈只能重新下載了最新的MySQL 5.7.17 Community 壓縮版 for Windows 64-bit。但在安裝過(guò)程中遇到了一些意外的問(wèn)題,通過(guò)查找相關(guān)資料也解決了,所以想著總結(jié)出來(lái),方便需要的朋友們可以參考借鑒,下面來(lái)一起看看吧。

首先下載最新的MySQL 5.7.17 Community 壓縮版 for Windows 64-bit:

官方下載地址:http://dev.mysql.com/downloads/mysql/

然后解壓到安裝目錄(如C:\Prog\MySQL\)。接下來(lái)復(fù)制my-default.ini為my.ini,修改my.ini如下:

[mysql]
default-character-set=utf8mb4

[mysqld]
basedir = C:\Prog\MySQL
datadir = C:\Prog\MySQL\data
port = 3306
max_connections=200
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
default-storage-engine=INNODB
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

之后用“管理員身份”打開cmd——“管理員身份”這很重要,進(jìn)入安裝目錄安裝MySQL服務(wù):

C:\Prog\MySQL\bin>mysqld install
Service successfully installed.

然后啟動(dòng)MySQL服務(wù):

net start mysql

剛開始以為就這么簡(jiǎn)單,可是幺蛾子的卻報(bào)錯(cuò)了:

如果是通過(guò)Windows系統(tǒng)的“服務(wù)”啟動(dòng),則提示:

問(wèn)題出得實(shí)在是心塞不已,查了許久,原來(lái)是:

If you installed MySQL using the Noinstall package, you may need to initialize the data directory:

  • Windows distributions prior to MySQL 5.7.7 include a data directory with a set of preinitialized accounts in the mysql database.
  • As of 5.7.7, Windows installation operations performed using the Noinstall package do not include a data directory. To initialize the data directory, use the instructions at Section 2.10.1.1, “Initializing the Data Directory Manually Using mysqld”.

具體可參考這兩個(gè)鏈接:

2.3.5.4 Initializing the Data Directory

2.10.1.1 Initializing the Data Directory Manually Using mysqld

原因找到了,那我們來(lái)手動(dòng)Initialize Data Directory一下?。?/p>

mysqld --defaults-file=C:\Prog\MySQL\my.ini --initialize-insecure

然后依次:

net start mysql
mysql -u root -p

熟悉的mysql>應(yīng)該就出來(lái)了。

希望對(duì)遇到類似坑的人有所幫助,究其原因就是5.7.7及以后的壓縮包版本,更改為需要手動(dòng)Initialize Data Directory了。

技無(wú)一招鮮,坑要一路填。

我的環(huán)境:

  • Windows 10 64-bit
  • MySQL Community Server 5.7.17 for Windows (x86, 64-bit), ZIP Archive

(分割線,以上MySQL 5.7.17就算安裝完畢了。)

最后手賤,搞個(gè)SQLAlchemy測(cè)試MySQL:

"""SQLAlchemy操作MySQL測(cè)試"""

from sqlalchemy import create_engine, Table, Column, Integer, MetaData
from sqlalchemy.dialects.mysql import CHAR
from sqlalchemy.sql import select

ENGINE = create_engine('mysql+pymysql://root:@127.0.0.1:3306/test?charset=utf8mb4')

CONN = ENGINE.connect()

USERINFO = Table('userinfo',
  MetaData(),
  Column('id', Integer, primary_key=True, autoincrement=True),
  Column('name', CHAR(24, charset='utf8mb4')),
  mysql_charset='utf8mb4')

USER = select([USERINFO])

RESULT = CONN.execute(USER)

for row in RESULT:
 print(row.name)

RESULT.close()
CONN.close()

結(jié)果發(fā)現(xiàn)輸出結(jié)果的同時(shí)有個(gè)報(bào)警:

Warning: (1366, "Incorrect string value: '\xD6\xD0\xB9\xFA\xB1\xEA...' for column 'VARIABLE_VALUE' at row 480")

這是怎么回事呢?要說(shuō)各種字符集設(shè)置都檢查n次,應(yīng)該沒(méi)啥問(wèn)題了......

 

無(wú)數(shù)次思考、試驗(yàn)中,發(fā)現(xiàn)了啥?發(fā)現(xiàn)了啥?發(fā)現(xiàn)只要show variables like '%charac%';一下,就會(huì)出來(lái)一個(gè)告警!

再來(lái)看看這個(gè)這個(gè)Warning:

 

不正是它嗎?MySQL的Bug莫不是?!OMG!

好吧!重回MySQL 5.6.35!

 

告警不見了!

接著重新建庫(kù)、建表,測(cè)試程序:

 

這下OK了,最終還是兜了一圈回到了MySQL 5.6.35。

安靜地寫Python,沒(méi)人吵,也不像前端撕來(lái)撕去的——?dú)q月靜好、Python靜好。

最后贊一下Visual Studio Code:

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望自己的一些經(jīng)驗(yàn)?zāi)軒偷酵瑯佑龅竭@些問(wèn)題的朋友們,如果有疑問(wèn)大家也可以留言交流。

相關(guān)文章

最新評(píng)論