1
You need to verify if MySQL is running on your server before executing the script.
Get-Service | Where-Object {$_.DisplayName -like "*MySQL*"}
If the service is stopped, start it using:
Start-Service -Name "MySQL80"
Also, check if the user executing the script has the necessary privileges to create a database:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
If you are using a non-root user, grant specific privileges:
GRANT ALL PRIVILEGES ON mydbsql.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword';