执行 SQL 脚本文件():
mysql –u root –p 123456 < script.sql
卸载 MySQL(需手动删除文件):
@echo offecho ==========获取管理员权限...=========%1 %2ver|find "5.">nul&&goto :gotAdminmshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :gotAdmin","","runas",1)(window.close)&goto :eof:gotAdmincd /d %~dp0echo ==========停止服务...===============net stop MySQLecho ==========删除服务...===============bin\mysqld --removeecho ==========结束!====================pause
安装 MySQL(my.ini 这里是在上级文件夹中存储):
@echo offecho ==========获取管理员权限...==========================%1 %2ver|find "5.">nul&&goto :gotAdminmshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :gotAdmin","","runas",1)(window.close)&goto :eof:gotAdmincd /d %~dp0echo ==========安装服务...================================bin\mysqld --install MySQL --defaults-file=%~dp0\my.iniecho ==========初始化...(datadir 目录必须为空)==========bin\mysqld --defaults-file=%~dp0\my.ini --initialize-insecure --consoleecho ==========运行服务...================================net start MySQLecho ==========修改 root 密码...==========================bin\mysql -u root --skip-password < change_password.sqlecho ==========结束!=====================================pause
change_password.sql
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';exit