skip to Main Content

Usually, I can start MySQL service on windows use command in the cmd window with administration privilege, like:
net start mysql
admin prompt
success start mysql
We can see it works well.
Sometimes, I dont wanna open the command prompt with administrative privileges. Instead, I prefer to use an already open command prompt window that isn’t running with administrative privileges. However, under these circumstances, the command to start the MySQL service doesn’t work.
start mysql with error
Opening a new command prompt with administrative privileges every time I need to start the MySQL service feels cumbersome. Is there a way to do this without such hassle?

Cannot start mysql service from normal privilege cmd window.

3

Answers


  1. Chosen as BEST ANSWER

    i see that i can use gsudo.

    the link: https://github.com/gerardog/gsudo

    After install it, i can use sudo like linux. Although it still requires UAC, it offers much more convenience.

    sudo net start mysql

    use gsudo to start service


  2. In the following article, you can find four methods for achieving what you need, each one described in detail: https://woshub.com/set-permissions-on-windows-service/
    In summary:

    • using sc.exe
    • using Process Explorer
    • using PowerShell
    • using Group Policy

    Hope this helps

    Login or Signup to reply.
  3. Just execute the RESTART command as a user which has shutdown privileges:

    mysql -uroot -p -e"restart" 
    

    Another option would be to use windows runas cmd, however this would require that user "Administrator" is enabled and that you know his credentials.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search