Last active
July 31, 2022 14:46
-
-
Save bitnbytesio/3875d9a521346cf6d56a5a5c30ec8d33 to your computer and use it in GitHub Desktop.
mysql-windows-noinstall-python3-scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.system("bin\mysqld --remove") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.system("bin\mysqld --console") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.system("bin\mysqladmin -u root shutdown") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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