Skip to content

Instantly share code, notes, and snippets.

@bitnbytesio
Last active July 31, 2022 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitnbytesio/3875d9a521346cf6d56a5a5c30ec8d33 to your computer and use it in GitHub Desktop.
Save bitnbytesio/3875d9a521346cf6d56a5a5c30ec8d33 to your computer and use it in GitHub Desktop.
mysql-windows-noinstall-python3-scripts
# setup file
# run as admin
import os
cwd = os.getcwd()
mysql_dir = cwd.replace("\\", '/')
mysql_ini_file = "my.ini"
# sys.argv
print(f"current working directory {cwd}")
if os.path.exists(mysql_ini_file):
os.remove(mysql_ini_file)
if not os.path.isfile(mysql_ini_file):
f = open(mysql_ini_file, "w")
f.write(f"""[mysqld]
# set basedir to your installation path
basedir={mysql_dir}
# set datadir to the location of your data directory
datadir={mysql_dir}/data
""")
f.close()
if not os.path.exists("data"):
os.makedirs("data")
os.system("bin\mysqld --initialize-insecure --console")
os.system("bin\mysqld --install-manual")
os.system("bin\mysqld --remove")
import os
os.system("bin\mysqld --console")
import os
os.system("bin\mysqladmin -u root shutdown")
# run as admin
import os
os.system('sc start MySQL')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment