使用此方式的好處就是,下次更新電腦的時候目錄直接複製(目錄名稱一致),直接執行 mysql-zip-install-batch.bat 批次檔案就可以了,資料庫、預存程序、Viewer、權限 都不用再設定。
安裝環境 : Windows XX想要安裝的目錄
- Install path
- D:\Data\AppServ\MySQL\MySQL-Server-56 (下載 mysql-5.6.24-winx64.zip 後檔案解壓縮路徑)
- data path
- D:\Data\AppServ\MySQL\data5.6
- my.ini path
- D:\Data\AppServ\MySQL\MySQL-Server-56
- mysql-installer-community-5.5.28.2
- mysql-installer-community-5.6.19.0
使用ZIP安裝
- 下載檔案
- D:\Data\Downloads\MySQL\2015.05.29\mysql-5.6.24-winx64\
- mysql-5.6.24-winx64.zip (或是選取其他較適合的版本)
- 準備 my.ini (以下目錄自行調整實際的目錄名稱)
- D:\Data\AppServ\MySQL\MySQL-Server-56\my.ini
[mysql] # Specify character settings per database
default-character-set=utf8
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
# set basedir to your installation path basedir=D:\Data\AppServ\MySQL\MySQL-Server-56
# set datadir to the location of your data directory
datadir=D:\Data\AppServ\MySQL\data5.6 #Specify character settings at server startup character-set-server=utf8
|
- 安裝過程問題處理
- cmd> SET SERVICE_NAME=Mysql56
- cmd> SET MYSQL_HOME=”D:\Data\AppServ\MySQL\MySQL-Server-56”
- cmd> SET MYSQL_INI="D:\Data\AppServ\MySQL\MySQL-Server-56"
- %MYSQL_HOME%\bin\mysqld.exe --remove %SERVICE_NAME%
- >> Install/Remove of the Service Denied!
- >> (解決方案) Run command prompt as administrator and try again.
- %MYSQL_HOME%\bin\mysqld.exe --install-manual %SERVICE_NAME% --defaults-file=%MYSQL_INI%\my.ini
- D:\>net start %SERVICE_NAME%
- mysql 服務正在啟動 ....
- mysql 服務無法啟動。
- 系統發生錯誤。
- 系統發生 1067 錯誤。
- 處理程序意外終止。
- >> Can't read from messagefile 'D:\mysql\share\errmsg.sys'
- >> (解決方案) Copy File : ..\mysql-5.6.24-winx64\share\english\errmsg.sys To D:\Data\AppServ\MySQL\MySQL-Server-56\share
- net start %SERVICE_NAME% ; always failed to start mysql service
- %MYSQL_HOME%\bin\mysqld" --console
- path 配置設定
- 編輯系統環境變數
- add path = D:\Data\AppServ\MySQL\MySQL-Server-56\bin
- 依據以上的步驟設定安裝批次
- File : D:\Data\AppServ\MySQL\mysql-zip-install-batch.bat
D:
CD D:\Data\AppServ\MySQL
REM 以上兩行可以省略
SET SERVICE_NAME=Mysql56
SET MYSQL_HOME=D:\Data\AppServ\MySQL\MySQL-Server-56
SET MYSQL_INI=D:\Data\AppServ\MySQL\MySQL-Server-56
net stop %SERVICE_NAME%
Pause
%MYSQL_HOME%\bin\mysqld.exe --remove %SERVICE_NAME%
%MYSQL_HOME%\bin\mysqld.exe --install-manual %SERVICE_NAME% --defaults-file=%MYSQL_INI%\my.ini
net start %SERVICE_NAME%
Echo Off
REM %MYSQL_HOME%\bin\mysqld --console
REM D:\Data\AppServ\MySQL\data56
Pause
|
以上服務手動啟動記得調整為自動啟動。
設定登入權限 (原來資料庫已經設定過,就不需要再設定)
- 建立 User : 'webuser'@'localhost'
- CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'web1234';
- GRANT USAGE ON *.* TO 'webuser'@'localhost' IDENTIFIED BY 'web1234' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
- GRANT ALL ON db1.* TO 'webuser'@localhost IDENTIFIED BY 'web1234';
- GRANT ALL ON db2.* TO 'webuser'@localhost IDENTIFIED BY 'web1234';
- GRANT ALL ON db3.* TO 'webuser'@localhost IDENTIFIED BY 'web1234';
- GRANT ALL ON db4.* TO 'webuser'@localhost IDENTIFIED BY 'web1234';
- GRANT SELECT ON mysql.proc TO 'webuser'@'localhost';
- Restore db
- db1 ~ db4
- Change root PWD :
- Open “Mysql Workbench" (或是使用 Mysql command)
- SET PASSWORD FOR 'root'@'localhost' = PASSWORD('abc1234')
No comments:
Post a Comment