亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

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

然后解壓到安裝目錄(如C:\Prog\MySQL\)。接下來復(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.

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

net start mysql

剛開始以為就這么簡單,可是幺蛾子的卻報錯了:

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

問題出得實在是心塞不已,查了許久,原來是:

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”.

具體可參考這兩個鏈接:

2.3.5.4 Initializing the Data Directory

2.10.1.1 Initializing the Data Directory Manually Using mysqld

原因找到了,那我們來手動Initialize Data Directory一下啊:

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

然后依次:

net start mysql
mysql -u root -p

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

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

技無一招鮮,坑要一路填。

我的環(huán)境:

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

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

最后手賤,搞個SQLAlchemy測試MySQL:

"""SQLAlchemy操作MySQL測試"""

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é)果的同時有個報警:

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

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

 

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

再來看看這個這個Warning:

 

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

好吧!重回MySQL 5.6.35!

 

告警不見了!

接著重新建庫、建表,測試程序:

 

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

安靜地寫Python,沒人吵,也不像前端撕來撕去的——歲月靜好、Python靜好。

最后贊一下Visual Studio Code:

總結(jié)

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

相關(guān)文章

最新評論