mysql_init.bat 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. @echo off
  2. rem ������·���л�����ǰ�ű�����Ŀ¼
  3. cd /d %~dp0
  4. rem ��ʼ��װmysql
  5. echo ----1.start installing Mysql ---->>../log.txt
  6. "%cd%\mysqld.exe" --initialize-insecure --user=mysql --console
  7. cd ..
  8. set "mysqlpath=%cd%">>../log.txt
  9. set basedir=%cd%
  10. set basedir=%basedir:\=/%
  11. >my.ini echo [mysqld]
  12. >>my.ini echo port=54042
  13. >>my.ini echo basedir=%basedir%
  14. >>my.ini echo datadir=%basedir%/Data
  15. >>my.ini echo max_connections=200
  16. >>my.ini echo max_connect_errors=10
  17. >>my.ini echo character-set-server=utf8mb4
  18. >>my.ini echo default-storage-engine=INNODB
  19. >>my.ini echo local_infile=ON
  20. >>my.ini echo.
  21. >>my.ini echo [mysql]
  22. >>my.ini echo default-character-set=utf8mb4
  23. >>my.ini echo local_infile=ON
  24. >>my.ini echo.
  25. >>my.ini echo [client]
  26. >>my.ini echo port=54042
  27. >>my.ini echo default-character-set=utf8mb4
  28. cd bin
  29. "%mysqlpath%\bin\mysqld.exe" install ctV2 --defaults-file="%mysqlpath%\my.ini"
  30. rem ����mysql��������
  31. echo ----2. start Mysql service---- >>../log.txt
  32. rem pause
  33. net start ctV2
  34. sc config ctV2 start= auto
  35. net stop ctV2
  36. net start ctV2
  37. rem ����mysql���������������д������ݿ��ʼ��
  38. echo ----3.setting Mysql environment ---->>../log.txt
  39. cd ..
  40. "%cd%\bin\mysqladmin" -u root password Mysql@.2020
  41. "%cd%\bin\mysql.exe" -uroot -pMysql@.2020 ct_v2 < "%cd%\sql\grant.sql"
  42. echo %Path%
  43. echo %Path%|find /i "%mysqlpath%" && set IsNull=true || set IsNull=false
  44. echo %IsNull%
  45. if not %IsNull%==true (
  46. wmic ENVIRONMENT create name="MYSQL_HOME_CTV2",username="<system>",VariableValue="%mysqlpath%"
  47. rem ׷��path����
  48. wmic ENVIRONMENT where "name='PATH' and username='<system>'" set VariableValue="%path%;%%MYSQL_HOME_CTV2%%\bin;"
  49. echo ----4. Mysql environment create/append success---->>/log.txt
  50. )
  51. pause >nul