MySql server is not starting from the command promt - mysql

I tried to start the server from MySQL application that is startup/shutdown
there iam getting an error MySQL cannot connect to localhost(10061) code 2003
After that I tried to connect it from cmd line ,but that is also not working
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld"
mysqld: Can't change dir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno 2 - No such file or directory)
2018-09-18T07:03:05.833751Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld (mysqld 8.0.12) starting as process 1472
2018-09-18T07:03:05.841119Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\LAPTOP-7VFDP9Q8.lower-test
2018-09-18T07:03:05.841308Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\LAPTOP-7VFDP9Q8.lower-test
2018-09-18T07:03:05.842165Z 0 [ERROR] [MY-010172] [Server] failed to set datadir to C:\Program Files\MySQL\MySQL Server 8.0\data\
2018-09-18T07:03:05.856689Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-09-18T07:03:05.858721Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.

No such file or directory
It's good hint. Check this path 'C:\Program Files\MySQL\MySQL Server 8.0\data\'
Maybe it not exists. If it's true - just create folder.
If folder already created - check datadir in your my.ini
Maybe you need quotes ("")
For example - check my my.ini

The reason behind this error is that the server is looking for the data directory to create a test file but cannot find one.
If you have installed MySQL workbench then the data folder might not exist at 'C:\Program Files\MySQL\MySQL Server 8.0\'.
First check whether the data folder is at 'C:\Program Files\MySQL\MySQL Server 8.0\' or not.
If not, you can copy the data folder from 'C:\Program Files\MySQL\MySQL Workbench 8.0 CE\' and paste it at 'C:\Program Files\MySQL\MySQL Server 8.0\'.
The command will execute without any error!

Related

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!

I have tried to reset MySQL root password tried 3 ways looking for an alternative? I am using a windows machine the command line

I used my windows cmd to go to the location of my MYSQLbin
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe
then navigated to the txt file I had created with the
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
--init-file=C:\passwordreset.txt
My first attempt I used the following method.
ALTER USER 'root'#'localhost'IDENTIFIED BY 'mypassword';
My second attempt I tried using
UPDATE mysql.user
SET authentication_string = PASSWORD('mypassword'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
Both did not work. I got in return a txt file when I entered the commands with the following
# Other default tuning values
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
Lastly I have tried
mysqld --skip-grant-tables
I got this response.
2021-08-19T10:41:11.580822Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.22) starting as process 6812
2021-08-19T10:41:11.806317Z 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-08-19T10:41:11.806436Z 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-08-19T10:41:11.807174Z 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-08-19T10:41:11.809151Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-08-19T10:41:11.839248Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.22) MySQL Community Server - GPL.
Any tips on solving this

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

OS errno 13 - Permission Denied MySQL Server

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.