標籤:mysql
1、把下載得到的mysql安裝包解壓後得到如下目錄結構
D:\JackGao\Downloads\mysql-5.7.10-winx64\bin
2、修改ini檔案:D:\JackGao\Downloads\mysql-5.7.10-winx64\my-default.ini
在[mysqld]後面添加
basedir=D:\JackGao\Downloads\mysql-5.7.10-winx64
datadir=D:\JackGao\Downloads\mysql-5.7.10-winx64\data
port=3306
#這一句解決有IPV6協議的電腦上預設採用IPV6協議導致無法從程式串連資料庫的問題
bind-address=127.0.0.1
# 允許最大串連數
max_connections = 200
# 服務端使用的字元集預設為8位元編碼的latin1字元集
character-set-server = utf8
# 建立新表時將使用的預設儲存引擎
default-storage-engine = INNODB
[client]
# 設定mysql用戶端預設字元集
default-character-set = utf8
3、mysql5.7.10沒有data目錄,所以要初始化,如果datadir指向的data目錄不存在,初始化的時候會建立
cmd> bin/mysqld --initialize-insecure --defaults-file=D:\JackGao\Downloads\mysql-5.7.10-winx64\my-default.ini
4、啟動mysqld,並且修改root密碼,關閉mysql直接關掉cmd視窗即可
cmd> mysqld --console
cmd> mysql -u root --skip-password
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘;
5、安裝mysqld服務,也可以不安裝服務
cmd> cd /d D:\JackGao\Downloads\mysql-5.7.10-winx64\bin
cmd> mysqld -install mysql --defaults-file="D:\JackGao\Downloads\mysql-5.7.10-winx64\my-default.ini"
cmd> mysqld -remove mysql
啟動mysql
cmd> net start mysql
關閉mysql
cmd> net stop mysql
安裝結束
參考資料:
http://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
-------------
The database must be initialized before MySQL can be started. For additional information about the initialization process, see Section 2.10.1.1, “Initializing the Data Directory Manually Using mysqld”.
To start the mysqld server from the command line, you should start a console window (or “DOS window”) and enter this command:
C:\> "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld"
The path to mysqld may vary depending on the install location of MySQL on your system.
You can stop the MySQL server by executing this command:
C:\> "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqladmin" -u root shutdown
-------------
2015-12-15T14:15:10.506825Z 0 [Note] InnoDB: not started
mysqld: Table ‘mysql.plugin‘ doesn‘t exist
2015-12-15T14:15:10.510825Z 0 [ERROR] Can‘t open the mysql.plugin table. Please run mysql_upgrade to create it.
2015-12-15T14:15:10.539827Z 0 [ERROR] Fatal error: Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exist
2015-12-15T14:15:10.540827Z 0 [ERROR] Aborting
shell> bin/mysqld --initialize (--console這個選項是把日誌輸出到命令列,否則就會把日誌輸出到datadir目錄的xx.err檔案中)
shell> bin/mysqld --initialize-insecure
Regardless of platform, use --initialize for “secure by default” installation (that is, including generation of a random initial root password). In this case, the password is marked as expired and you will need to choose a new one. With the --initialize-insecure option, no root password is generated; it is assumed that you will assign a password to the account in timely fashion before putting the server into production use.
-------------------------------
使用5個步驟完成在windows7下安裝mysql-5.7.10-winx64.zip