OS errno 13 - Permission Denied MySQL Server - mysql

I'm having issues with MySQL workbench - I can't seem to start the server. In the command line, I navigate to:
C:\Program Files\MySQL\MySQL Server 8.0\bin\
And then run mysqld --initialize
I get the following error:
mysqld: Can't create directory 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno 13 - Permission denied)
2018-12-10T23:18:55.211840Z 0 [System] [MY-013169] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 36568
2018-12-10T23:18:55.227851Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-12-10T23:18:55.230796Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL.
Can anyone tell me how to fix this issue? I already checked the permissions on the MySQL Server 8.0 folder, and have set all the permissions to Allow.

You have to give writing permissions to the following folders:
PATH/DATA/
PATH/QUERIES/
PATH/LOG/
for the user who starts the MySQL windows service, which if not a special one you created and use for such purpose, is NETWORK SERVICE.

Related

mysqld: File '.\binlog.index' not found (OS errno 13 - Permission denied)

its a duplicate question but i still cannot solve this problem.
I have forgotten my MySQL root user password and i followed this troubleshoot steps https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
upon running the command
mysqld --init-file=C:\\mysql-init.txt --console
it gives following output
2022-09-26T12:10:19.366600Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.30) starting as process 7280
2022-09-26T12:10:19.368952Z 0 [Warning] [MY-010091][Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2022-09-26T12:10:19.369022Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test mysqld: File '.\binlog.index' not found (OS errno 13 - Permission denied)
2022-09-26T12:10:19.371806Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-09-26T12:10:19.372077Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
i cannot even run
mysql
it gives following error
ERROR 1045 (28000): Access denied for user 'ODBC'#'localhost' (using
password: NO)
I am not sure what is wrong here.
i got it working after several more steps other than those mentions in the document.
After FreudianSlip comments to make sure to start mysqld as administrator i got rid of these error but it still didnt work . what actually worked is mentioned in this comment https://stackoverflow.com/a/65214867/19982606

MySQL Server cannot start

Whenever I try to start mysql server using this command,
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld"
It returns me this error and server won't start
2022-01-14T04:31:15.902534Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld (mysqld 8.0.27) starting as process 3380
2022-01-14T04:31:15.908243Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2022-01-14T04:31:15.908376Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2022-01-14T04:31:15.908671Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2022-01-14T04:31:15.909424Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-01-14T04:31:15.909709Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld: Shutdown complete (mysqld 8.0.27) MySQL Community Server - GPL.
I really appreciate your help thanks.
1.Go to Services tab on your windows and check whether MySQL running or not.
2.Adding MySQL to path,
Open "Edit system variables".
Click on "Environment variables"
Click on "Path" and click on "Edit"
Click on "New" and paste your MySQL path.
(C:\Program Files\MySQL\MySQL Shell 8.0\bin)
3.From doing above scenarios you don't need to call your MySQL path every time you want to run MySQL using command line.
4.Now open command line and type this (Here -u is username and -p is password),
mysql -u root -p (After typing hit enter).
It will ask for your password, if you have no password just hit enter

Cannot reinstall MySql "Could not connect to MySql with the given password" on Windows. Forgot root password

I am learning Spring Batch. I followed the instructions to install MySQL Shell 8.0.26 and also the Workbench 8.0 on Windows 11.
However I get
MySQL JS > alter user 'root'#'localhost' IDENTIFIED WITH mysql_native_password by 'password';
SyntaxError: Unexpected identifier
MySQL JS > show schemas;
SyntaxError: Unexpected identifier
MySQL JS > show databases;
So I tried to uninstall and reinstall MySql.
When I run the installer,
I have forgotten the root password. What should I do?
In this similar SO question the person remembered the password.
I did an internet search and tried to follow the steps here
https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
C:\Program Files\MySQL\MySQL Server 8.0\bin>.\\mysqld --init-file=C:\\Documents\\mysql-init.txt
2021-11-15T00:37:15.052478Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.26) starting as process 5260
2021-11-15T00:37:15.054496Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2021-11-15T00:37:15.054535Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2021-11-15T00:37:15.054651Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2021-11-15T00:37:15.056382Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-11-15T00:37:15.056496Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.26) MySQL Community Server - GPL.
C:\Program Files\MySQL\MySQL Server 8.0\bin>
I found this article and it says that one must manually delete the following folders. Merely Uninstalling from Windows Control Panel is not enough.
C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL
https://answers.microsoft.com/en-us/windows/forum/windows_other-windows_programs/how-to-completely-uninstall-mysql/e90e1344-7b90-4319-8b2f-77b271ae66ed
I followed the steps and when I ran the installer again, it asked for a new root password!

Getting error while trying to reset forgot root password in MySQL8?

I tried most of the troubleshooting steps available online .But I am not getting the solution.I forgot my root password .I tried creating the init file and loaded with data given online and tried it with cmd prompt .Then I tried using update commands to remove the password
Error snaps -> https://i.stack.imgur.com/tfFR6.jpg
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\chitr>cd C:\Program Files\MySQL\MySQL Server 8.0\bin
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqld.exe -u root --skip-grant-tables
2019-11-11T18:39:05.755671Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.18) starting as process 11668
2019-11-11T18:39:05.758635Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2019-11-11T18:39:05.758740Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2019-11-11T18:39:05.758887Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2019-11-11T18:39:05.777215Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-11-11T18:39:05.777347Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL.
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql --version
mysql Ver 8.0.18 for Win64 on x86_64 (MySQL Community Server - GPL)
C:\Program Files\MySQL\MySQL Server 8.0\bin>sudo systemctl stop mysql.service
'sudo' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\MySQL\MySQL Server 8.0\bin>sudo /etc/init.d/mysql stop
'sudo' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqld --console
2019-11-11T18:58:41.814544Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.18) starting as process 10004
2019-11-11T18:58:41.817402Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2019-11-11T18:58:41.817505Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2019-11-11T18:58:41.817645Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2019-11-11T18:58:41.833930Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-11-11T18:58:41.834045Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL.
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqld --init-file=C:\Program Files\MySQL\MySQL Server 8.0\bin --console
2019-11-11T18:59:31.764265Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.18) starting as process 13568
2019-11-11T18:59:31.767450Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2019-11-11T18:59:31.767595Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2019-11-11T18:59:31.767780Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2019-11-11T18:59:31.788066Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-11-11T18:59:31.788210Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL.
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p
Enter password: **********
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)```
[1]: https://i.stack.imgur.com/tfFR6.jpg
Manually creating a 'data' folder in the mysql installation folder seems to work. That's what the error says, it can't write into the data folder, most probably because it doesn't exist.
It's an old thread but I just encountered the same issue.
You should have posted also which tutorials you used.
That from your log seems to be for linux.
Use this simple solution for windows
https://dev.mysql.com/doc/mysql-windows-excerpt/8.0/en/resetting-permissions-windows.html
And follow it to the letter.
This problem boils down to administrator privileges. (I) don't use sudo commands in windows. Close the command prompt window, then run a fresh one as administrator and follow the exact procedure highlighted here: https://dev.mysql.com/doc/mysql-windows-excerpt/8.0/en/resetting-permissions-windows.html

MySQL: mysqld in cmd returns "Can't change dir to..."

I've just joined to ask for help regarding this.
Whenever I type mysqld in CMD I get the following:
mysqld: Can't change dir to 'c:\Program Files\MySQL\MySQL Server 8.0\data\' (OS
errno 2 - No such file or directory)
2018-08-12T09:16:41.903311Z 0 [System] [MY-010116] [Server] c:\Program Files\MyS
QL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.12) starting as process 2740
2018-08-12T09:16:41.965711Z 0 [Warning] [MY-010091] [Server] Can't create test f
ile c:\Program Files\MySQL\MySQL Server 8.0\data\Moonwilles-PC.lower-test
2018-08-12T09:16:41.965711Z 0 [Warning] [MY-010091] [Server] Can't create test f
ile c:\Program Files\MySQL\MySQL Server 8.0\data\Moonwilles-PC.lower-test
2018-08-12T09:16:41.965711Z 0 [ERROR] [MY-010172] [Server] failed to set datadir
to c:\Program Files\MySQL\MySQL Server 8.0\data\
2018-08-12T09:16:41.965711Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-08-12T09:16:41.965711Z 0 [System] [MY-010910] [Server] c:\Program Files\MyS
QL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.12) MySQL Com
munity Server - GPL.
I've looked literally everywhere, I installed MySQL using the MySQL installer on 3 different computers, I got the same problem on all of them. This is the most ridiculous and frustrating thing I've ever encountered.
The MySQL service is on.
I tried typing mysqld --initialize and it seems to have made things worse as whenever I type 'mysqld' CMD now 'freezes' momentarily before actually executing the command.
The 'my.ini' file is setup correctly.
The data directory is in 'C:\ProgramData\MySQL\MySQL Server 8.0\Data'.
I've forgotten my root password and I am trying to recover it. I followed the guide found here: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html and it's not even working.
I cannot log in to phpMyAdmin anymore.