I followed the mysql 5.6 manual's instructions to reset my root password, but it is not working. I also tried using the '--skip-grant-tables' option based on this question. Still not working.
I am using windows 7 and MySQL 5.6, it is running as a service. Here is exactly what I did:
First, I did steps 1 to 5 from this procedure, to stop the MySQL service, and create my init file. This is my init file, with the password censored:
UPDATE mysql.user SET Password=PASSWORD('**********') WHERE User='root';
FLUSH PRIVILEGES;
I also checked the properties on my service, and it does have the correct path to MySQL5.6
Then in a new terminal did this:
C:\Users\michael>"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --init-file=C:\Users\michael\mysql-init.txt --skip-grant-tables
2014-10-13 10:18:10 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
After that, the terminal was no longer usable, I could not do ctrl+c, nor type anything. So I opened a new terminal and tested logging in with that password, it worked.
At that point it was not running as a service. The only way I could think of stopping mysqld was by using the task manager, since ctrl+c in the terminal was not working, and closing the terminal did not stop mysqld. After I stopped it from the task manager, I went back to my services window and started mysql as a service.
Unfortunately though, I tried logging in again, using the same password that worked moments ago, and I am still being denied access:
C:\Users\michael>mysql -uroot -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
what am I missing?
Related
I've been trying to reset my password in Mysql for five hours now. When I write:
mysql -u root -p
I get
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I should also add that my MySql server is running according to system preferences.
When I try the solutions on mentioned here
which says to try
/usr/local/opt/mysql/bin/mysqladmin -u root password 'new-password'
I can't do that because there is no such path on my computer. And in the folder /usr/local/mysql/bin/ there is no file called mysqladmin
That site also recommends
Select System Preferences... from the Apple menu and click the Network app to launch it as shown below.
Click your WiFi connection to select it
Click the Advanced... option
Click the Proxies tab to select it
Check the top 3 options Auto Proxy Discovery Automatic Proxy Configuration Web Proxy (HTTP)
Click OK.
Click Apply.
Quit System Preferences.
But that does not work either.
for reset password for mysql user root as follows:
UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';
By watching this video I was able to solve the problem.
I stopped the mysql server then input
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
I then got this output
2022-07-26T06:19:17.6NZ mysqld_safe Logging to '/usr/local/mysql/data/Admins-MacBook-Pro-4.local.err'.
2022-07-26T06:19:17.6NZ mysqld_safe Logging to '/usr/local/mysql/data/Admins-MacBook-Pro-4.local.err'.
2022-07-26T06:19:17.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
which also turned the mysql server back on. That's all it took.
so i installed the MySQL application for the first time. firstly i saw the command line client is not opening so i searched for solutions. they said i must go to the bin directory and run it manually. and after i run the cmd mysql -uroot -p and run it and enter password, it gives me the error: ERROR 1045 (28000): Access denied for user 'root'#'localhost' i tried every single solution on stackoverflow including disabling permissions, running manually which i mentioned above, starting the service from service.msc, running it with password and without.... it just doesnt want to work.
appreciate any help in advance.
GENERIC MYSQL INFO
To start with, read the mysql manual: https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
The steps will show you how to shut down the service and start it with an overriding command that doesn't require passwords, then you reset the password. From the manual:
Stop the MySQL server, then restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges and disables account-management statements such as ALTER USER and SET PASSWORD. Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'#'localhost' account password. Replace the password with the password that you want to use. To change the password for a root account with a different hostname part, modify the instructions to use that hostname.
MySQL 5.7.6 and later:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
mysql> SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
Or directly on the user table:
UPDATE mysql.user SET password=PASSWORD('mynewpassword') WHERE user='root';
XAMPP SPECIFIC
Stop the MySQL service. Open a command window. Change to the XAMPP MySQL directory:
> cd \xampp\mysql\bin\
Run the service without security (note you are running mysqld, not mysql):
> mysqld.exe --skip-grant-tables
The MySQL service will be running in this window, so open another command window and switch to the XAMPP MySQL directory:
> cd \xampp\mysql\bin\
Run the MySQL client:
> mysql
Update the password:
mysql> UPDATE mysql.user SET password=PASSWORD('mynewpassword') WHERE user='root';
Exit MySQL:
mysql> \q
Use task manager to cancel the mysqld.exe that is still running. Restart the mysql service.
I got the answer myself. Seemingly, if you get this error, it means that you need to reset your password. You can learn how to do that in MySQL from this link.
And don't forget to change the 5.7 version with your currently installed version in using commands (mine was 8.0).
After that, everything was working fine for me.
I'm using MySQL on windows (I wish I was using Mac, but due to some issues I'm using Bootcamp), and I've encountered a problem I think I've encountered before: the error that is written in the title. I think I might have solved this once before by erasing MySQL through the control panel and by erasing everything in the hidden folder, ProgramData, and MySQL from ProgramFiles, then reinstalling it. It is such a hassle and consumes a lot of time. It definitely isn't something I can do repeatedly to solve this problem if I get an error like this again and again.
The problem:
I simply ran this code on CMD after "cd"ing to the bin folder that contains mysql: mysql -u root -p PASSWORD but I get the error written in the title. Thus I can't login to mysql and run any lines to edit the database.
There are so many other topics like this in stackoverflow:
MySQL Error: : 'Access denied for user 'root'#'localhost'
Access Denied for User 'root'#'localhost' (using password: YES) - No Privileges?
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
I tried implementing the solutions from the three links above. Many other advices advise to use the "sudo" command, which is not a windows command.
This is the line I get from implementing the solution given to me by dev.mysql.com (#3):
This is the line of code I ran in CMD:
mysqld --init-file=C:\\mysql-init.txt --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console
This is the code I ran to implement the solution in link #2:
mysqld --skip-grant-tables --skip-networking --console
and the code I get back:
Things to note:
Each time, I get this line of code back from the console:
[Warning]...[Server] CA certificate ca.pem is self signed.
In the first picture, this is the "ERROR" I get from the console: [ERROR]...[Server] unknown variable 'defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini'
In the second picture, this is the "ERROR" I get from the console: [ERROR] TCP/IP --shared memory, or --named-pipe should be configured on NT OS
This is the line of code I would put in in mysql-init.txt: ALTER USER 'root'#'localhost' IDENTIFIED BY 'PASSWORDHERE';
or this: INSERT INTO mysql.user (Host, User, Password) VALUES ('%', 'root', password('YOURPASSWORD'));
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
I installed MySQL through the installation wizard.
Q. How did I encounter this error?:
A. I was experimenting on a project for a back-end Spring Boot project that uses JPA and JDBC combined. I got errors telling me that no datasource could be configured.
Q.How did my root password get reset?
A.I think they got reset because of JPA's datasource autoconfiguration. I didn't touch any of mysql's settings myself. Something I did on Spring Boot and its automatic configuration to localhost must have reset the password.
I will say that uninstall your MySQL and again install it with a new instance but not like just uninstall it from the control panel that's why you are facing the same error every time. I already answered here in detail that how to remove properly so no error will come by creating a new instance.
For anyone encountering this issue after they initialized their mysql server with following command:
mysqld --initialize
Look out for the last output of the process, it should say something like this:
[Note] [MY-010454] [Server] A temporary password is generated for root#localhost: password12345
there is your temporary password to log in.
I can connect to mysql database without issue after resetting the root password:
C:\\> C:\mysql\bin\mysqld-nt --init-file=C:\\\\mysql-init.txt
where mysql-init.txt contains:
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
However, every time I reboot windows, I get this error message when I try to connect to the database:
C:\\>mysql -u root -p
Enter Password: ********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I have also tried without a password, same failure.
It doesn't seem like a good practice to reset the root password every time I reboot. Is this a known issue with a known fix?
The correct way is , like following.
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list and stop it.
If your server is not running as a service, you may need to use the Task Manager to force it to stop.
Create a text file containing the following statements. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Write the UPDATE and FLUSH statements each on a single line. The UPDATE statement resets the password for all root accounts, and the FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
Save the file. For this example, the file will be named C:\mysql-init.txt.
Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:\> C:\mysql\bin\mysqld-nt --init-file=C:\\mysql-init.txt
If you installed MySQL to a location other than C:\mysql, adjust the command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing each root account password.
You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option:
C:\> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe"
--defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini"
--init-file=C:\\mysql-init.txt
The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.
After the server has started successfully, delete C:\mysql-init.txt.
I have spent many hours reading and trying dozens of variations of ways to reset the root password, but I am not getting anywhere. The most complete set of instructions I found (and tried) were the following. BTW, I am running MySQL 5.5 on Win7, 32 bit.
I created a file, c:\mysqlinit.txt, containing the two lines:
UPDATE mysql.user SET Password=PASSWORD('myroot') WHERE User='root';
flush privileges;
Stopped the MySQL55 Service from Control Panel, Admin Tools, Services
Opened a Command prompt window (running as the admin)
Navigated to \Program Files\MySQL\MySQL Server 5.5\bin\
Executed the command
start mysqld --init-file=C:\mysqlinit.txt
Everything seemed to work fine (no errors). At the completion of this procedure, I thought I could log on with the root user name and the above password, but when I executed the command
mysql -u root
I received the error message,
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
I am probably doing something wrong, but can't spot it and it is driving me nuts.
A can reset password in windows with this steps:
1) Stop running Mysql service first (Administrative tools > Services )
2) "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" -u root --skip-grant-tables
3) uninstall mysql server
4) install mysql server and set in installation:
root current password - it's must be blank
new password - set your new passowrd
confirmation new password - set your new passowrd
also there I added new admin user konst