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.
Related
I've searched a lot but nothing works for me.
I have a fresh installation of a LAMP server, installed via tasksel command.
My system runs php 7.4 and MySql 8
For some reason root user (that in my case is called phpmyadmin, by default) has no privileges on the DBs.
I can log in, so I'm sure the password is correct, but I cannot create a Database.
$ mysql -u phpmyadmin -p
mysql > create database test;
Access denied for user 'phpmyadmin'#'localhost' to database 'test'
EDIT
As suggested, here's the output of
mysql> SELECT name, Create_priv FROM mysql.user;
SELECT command denied to user 'phpmyadmin'#'localhost' for table 'user'
NEW EDIT
I tried to access without the password, following the guide reported here:
...
No results for me :(
Stop the MySQL Server: sudo /etc/init.d/mysql stop (OK)
Start the mysqld configuration: sudo mysqld --skip-grant-tables
output:
[2] 2345
[1] Exit 1 sudo mysqld --skip-grant-tables
Run: sudo service mysql start
output
[2]+ Exit 1 sudo mysqld --skip-grant-tables
It seems to exit with errors... Am I wrong?
I also tried to login in that situation, but I receive this message "ERROR 1698 (28000) Access denied for user 'root'#'localhost'"
If I try my phpmyadmin user, the message is "ERROR 1045 (28000): Access denied for user 'phpmyadmin'#'localhost' (using password: NO)"
EDIT 06/19/2020
I followed the steps reported here
How to reset or change the MySQL root password?
I had to use MD5() instead of PASSWORD() because it's now deprecated.
There's still something wrong.
Now I can access the database with no privileges and set/change my password.
Then I can flush all privileges.
Then I try...
mysql -u root -p
I enter my new password...
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
I can still log in with the user set in phpMyAdmin, but there are still no privileges for me.
I also reinstalled MySql server.
I remember I had a similar problem last time I installed an old Linux Virtual Machine, but I solved that issue easily. Now I'm wondering what's wrong :(
SOLVED
I reinstalled my virtual machine and installed manually both php and mysql server.
To be sure to set privileges in the right way I followed this small guide... maybe helpful for someone.
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04
Bye!
I'm having a weird problem where I cannot login to my MySQL server with sudo as root on a ubuntu 19.10 server. I want to be able to reset my root password.
The error message I got was:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Anyone had similar problems? Thanks!
Ok - so I solved this problem myself.
The correct way of resetting the root password for mysql is to:
Stop all mysql server sessions.
Start mysqld manually using - this basically tells MySQL to skip any credentials check and allow anyone to login, hence you want to skip-networking to avoid network users.
sudo mysqld --skip-grant-tables --skip-networking
Use this to login as root:
sudo mysql -u root
In the mysql prompt, do:
FLUSH PRIVILEGES;
SET PASSWORD FOR root#'localhost' = PASSWORD('password');
FLUSH PRIVILEGES;
Stop mysqld and restart mysql normally (you may need to kill the mysqld process).
In my case, there was some problems with the installation and the /var/run/mysqld folder was not correctly set up. It may be a bug with MySQL and it was not properly reported.
After creating the folder with the correct setmod (user:group is mysql:mysql) mysqld runs without any problem.
I am trying to install mysql in my macbook pro (OS version: 10.15.2).
These are the steps I followed
Install mysql community server from this link
Install mysql workbench from this link
Open mysql from system preferences and click initialize database
set password for root user under initialize database
open .bash_profile through terminal and set path for mysql
export PATH=${PATH}:/usr/local/mysql/bin/
restart terminal to start mysql server with the following command
mysql -u root -p
enter the password set for root user from step 4
After all this I get the following error
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Not sure what I am doing wrong.
This is the video I followed to install mysql in my system
[EDIT 1]
staring server with -skip-grant-tables
sudo mysqld_safe --skip-grant-tables
OUTPUT
2020-02-25T05:27:00.6NZ mysqld_safe Logging to '/usr/local/mysql/data/SASHAANKs-MacBook-Pro.local.err'.
2020-02-25T05:27:00.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2020-02-25T05:27:02.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/SASHAANKs-MacBook-Pro.local.pid ended
I believe the default authentication mechanism in MySQL 8 is auth socket. Try setting the root password like this:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'my_password';
More on this here: https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
If you can't access the CLI interface at all you should try manually resetting the root password as outlined here: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
Restart the mysql server with the --skip-grant-tables option.
Connect to the CLI (no password should be necessary)
FLUSH PRIVILEGES;
Reset root password as described above: ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'my_password';
Restart mysql normally
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?
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