1.設置環境變量
無論是用戶環境變量還是系統環境變量
2.安裝服務
進入根目錄
名字根據 --install 后的 參數來決定 叫MariaDB,MySQL 都可以
mysqld.exe --install MariaDB
Service successfully installed.
安裝通過ini配置文件(不配置環境變量, 一定要通過這種方式 來安裝服務)
mysqld.exe --install MariaDB --defaults-file=D:\DB\my.ini
最后可以看到服務的配置[屬性]中, [可執行文件路徑], 有以下信息
D:\Program\MariaDB\mariadb-10.3.12-winx64\bin\mysqld.exe --defaults-file=D:\DB\my.ini MariaDB
3.卸載服務
mysqld.exe --remove MariaDB
Service successfully removed.
4.啟動服務
net start MariaDB
MariaDB服務正在啟動 .
MariaDB服務已經啟動成功。
5.停止服務
net stop MariaDB
MariaDB服務正在停止.
MariaDB服務已成功停止。
.\mysql_install_db.exe
-?, --help Display this help message and exit.
-d, --datadir=name Data directory of the new database
-S, --service=name Name of the Windows service
-p, --password=name Root password
-P, --port=# mysql port
-W, --socket=name named pipe name (if missing, it will be set the same as
service)
-D, --default-user Create default user
-R, --allow-remote-root-access
Allows remote access from network for user root
-N, --skip-networking
Do not use TCP connections, use pipe instead
-i, --innodb-page-size=#
Page size for innodb
-s, --silent Print less information
-o, --verbose-bootstrap
Include mysqld bootstrap output
FATAL ERROR: parameter --datadir=# is mandatory
PS D:\Program\MariaDB\mariadb-10.3.12-winx64\bin> .\mysql_install_db.exe -d D:\DB -S MariaDB
Running bootstrap
2019-02-13 16:46:10 0 [Note] D:\Program\MariaDB\mariadb-10.3.12-winx64\bin\mysqld.exe (mysqld 10.3.12-MariaDB) starting as process 9212 ...
Removing default user
Creating my.ini file
Registering service 'MariaDB'
Creation of the database was successful
在服務可以看到
"D:\Program\MariaDB\mariadb-10.3.12-winx64\bin\mysqld.exe" "--defaults-file=D:\DB\my.ini" "MariaDB"
卸載
mysqld.exe安裝的服務,卸載必須用cmd(管理員權限) , powershell中 sc 命令無效
調用sc delete mariaDB
[SC] DeleteService 成功
- 命令行方式啟動
mysqld.exe --console