mysqld: Can't change dir to data. Server doesn't start

后端 未结 14 1273
失恋的感觉
失恋的感觉 2020-12-07 13:16

I installed a MySQL server with installer and it started. After reboot I tried to start it again and get the error:

D:\\Program Files\\MySQL\\MySQL Server 5.         


        
相关标签:
14条回答
  • 2020-12-07 13:22

    First run

    mysqld -u root --initialize-insecure 
    

    It will create data folder with root as user without password. Then run

    mysqld.exe -u root --console
    
    0 讨论(0)
  • 2020-12-07 13:22

    remove all files in "{path-to-mysql}\data" directory and run:

    mysqld --initialize-insecure --basedir={path-to-mysql}\mysql --datadir={path-to-mysql}\data --console
    
    0 讨论(0)
  • 2020-12-07 13:26

    I have met same problem. In my case I had no ..\data dir in my C:\mysql\ so I just executed mysqld --initialize command from c:\mysql\bin\ directory and I got the data directory in c:\mysql\data. Afterwards I could use mysqld.exe --console command to test the server startup.

    0 讨论(0)
  • 2020-12-07 13:29

    mariofertc completely solved this for me here are his steps:

    1. Verify mysql's data directory is empty (before you delete it though, save the err file for your records).

    2. Under the mysql bin path run: mysqld.exe --initialize-insecure

    3. add to my.ini (mysql's configuration file) the following: [mysqld] default_authentication_plugin=mysql_native_password

    Then check services (via task manager) to make sure MySql is running, if not - right click MySql and start it.

    I'll also note, if you don't have your mysql configuration file in the mysql bin and can't find it via the windows search, you will want to look for it in C:\Program Data\Mysql\ Note that it might be a different name other than my.ini, like a template, as Heesu mentions here: Can't find my.ini (mysql 5.7) Just find the template that matches the version of your mysql via the command mysql --version

    0 讨论(0)
  • 2020-12-07 13:29

    If you installed MySQL Server using the Windows installer and as a Window's service, then you can start MySQL Server using PowerShell and experience the convenience of not leaving the command line.

    Open PowerShell and run the following command:

    Get-Service *sql*
    

    A list of MySQL services will be retrieved and displayed. Choose the one that you want and run the following command while replacing service-name with the actual service name:

    Start-Service -Name service-name
    

    Done. You can check that the service is running by running the command Get-Service *sql* again and checking the status of the service.

    0 讨论(0)
  • 2020-12-07 13:30

    When I encountered this same error, I noticed MySQL Configuration file in "C:\Program Files\MySQL\MySQL Server X.Y\" has changed to my-default.ini

    I solved it by

    1. Copy my.ini from "C:\ProgramData\MySQL\MySQL Server X.Y\my.ini"
    2. Paste it in "C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
    3. Restart MySQL Server from services.msc

    In the .ini file, their is part that reads:

    # On Windows you should keep this file in the installation directory 
    # of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
    # make sure the server reads the config file use the startup option 
    # "--defaults-file". 
    
    0 讨论(0)
提交回复
热议问题