安装windwos服务初始化
@echo off cd /D %~dp0 set basepath=%~dp0 set servicename=MySQL cd %basepath%bin echo initialize mysqld --initialize-insecure echo install service mysqld --install %servicename% echo start mysql net start %servicename% pause
修改密码
@echo off echo use mysql; >d:\mysqlpass.txt echo update user set authentication_string=password('root') where user='123456' and Host='localhost'; >>d:\mysqlpass.txt echo CREATE USER `root`@`%%` IDENTIFIED BY '123456'; >>d:\mysqlpass.txt echo GRANT Alter, Alter Routine, Create, Create Routine, Create Temporary Tables, Create User, Create View, Delete, Drop, Event, Execute, File, Grant Option, Index, Insert, Lock Tables, Process, References, Reload, Replication Client, Replication Slave, Select, Show Databases, Show View, Shutdown, Super, Trigger, Update ON *.* TO `root`@`%%`; >>d:\mysqlpass.txt echo flush privileges; >>d:\mysqlpass.txt CD /D %~dp0 set basepath=%~dp0 cd %basepath%bin mysql -hlocalhost -uroot <d:\mysqlpass.txt del d:\mysqlpass.txt /f echo success pause RENAME USER `root`@`localhost` TO `root`@`%`;
重启服务
@echo off set servicename=MySQL net stop %servicename% net start %servicename% pause
卸载
@echo off cd /D %~dp0 set basepath=%~dp0 set servicename=MySQL cd %basepath%bin net stop %servicename% echo stop success mysqld.exe --remove %servicename% pause
标签:servicename%,set,dp0,echo,mysql,cd,安装 From: https://www.cnblogs.com/gzhq/p/17893179.html