Ive had mysql up and running for month now. I was using it yesterday, and today I go to login via phpmyadmin and the command line and I suddenly can't. Its as if someone changed my password overnight or something. Im trying to login using the root user. What do I do?
Edit
This is mysql just running on my local laptop for development. The only account on it is the root account, and no caps lock is not on.
http://www.cyberciti.biz/tips/recover-mysql-root-password.html says this five step process will work, try at your own risk obviously. This source also has essentially the same steps. This likely won't work on windows, but something similar should http://www.debian-administration.org/articles/442
Stop mysql service using /etc/init.d/mysql stop
Start mysql without password using mysqld_safe --skip-grant-tables &
Connect to the server using mysql -u root
Change the root password:
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
Stop the Server: /etc/init.d/mysql stop
Start the Server: /etc/init.d/mysql start
Test: mysql -u root -p
I used the link raina77ow provided and followed the instructions to reset my password and it works now.
Scrolling down to section C.5.4.1.3. Resetting the Root Password: Generic Instructions was particularly helpful.
Related
I understand that this is the safest way to change or reset mysql root password. I'm doing it because 8 times out of 10 the installation program won't prompt me for a root password.
So I run commands:
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root
use mysql;
Then, depending on your version of mysql or maria you're using you type:
update user set password=PASSWORD("mynewpassword") where User='root';
or
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
In my case I typed the first one. Then I refresh privileges by:
flush privileges; and then I exit out of mysql by typing: quit.
At this point everything went well. Then I restart mysql server by:
sudo /etc/init.d/mysql start
I get "OK" from the terminal. However, when I attempt to log in as root
I get pleasant error message saying:
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
I'm 100% confident that I'm typing correct password. Why is this happening ?
Problem resolved by backing up all important data and reinstalling the operating system. As turned out I had some broken packages that affected how mysql authentication worked. Standard steps to fix broken packages was no use so I wiped out HDD and started over.
MySQL was installed without any hiccups and was even prompted for a root password to be set. Now MySQL authentication works like a charm.
Try this out :- It Works for me..!!
Stop the MySQL server process.
service mysql stop
Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password.
mysqld_safe --skip-grant-tables > /dev/null 2>&1 &
Connect to mysql server as the root user. And Setup new mysql root account password.
mysql -u root -e "use mysql; update user set password=PASSWORD('NEW-PASSWORD') where User='root'; flush privileges;"
Exit and restart the MySQL server.
service mysql restart
Note: You may need to wait after mysqld_safe command, before you can run subsequent mysql command.
Now run :- mysql -u root -p
(After two hours of researching how to use mysql commands in the terminal, I can finally post this question, BTW if anyone with macOS is having the same trouble that can't use mysql commands in the terminal, go straight to this straight to this link: solution.)
I have a Mac os Sierra, I'm completely new to MySQL. I first downloaded the workbench and the MySql server, it gave me a temp password, I created a local connection, it worked. Then, I deleted the old connection, and created another connection, it asks for the password, and it wouldn't work, so right now I'm trying to reset and change my mysql password, but I've been having a lot of trouble with it.
Since the SQL office website only has instructions for windows and unix, and I'm rather new to bash, I tried to find solutions somewhere else like this site.
1. Attempt
When I tried the solution from this link site1, as I try the first step, it asks for a password which I don't have, I tried the old password just to try and it didn't work.
YupengdeMacBook-Pro:~ yinyupeng$ sudo /usr/local/mysql/support-files/mysql.server stop
Password:
Then, I realized that I can close my server directly in the MacOS setting, I did that, and I jumped to the second step directly, it still asks for a password:
YupengdeMacBook-Pro:~ yinyupeng$ sudo mysqld_safe --skip-grant-tables
Password:
So I'm stuck here, can't go further with this solution.
2. Attempt
then I tried this site2, but as I type the first line, it tells me this:
YupengdeMacBook-Pro:~ yinyupeng$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Umm... ok, so then I tried to find solutions for that "access denied" error, but with little results.
So I'm not sure what to do now, please help, thank you very much.
BTW, my SQL version is:
YupengdeMacBook-Pro:~ yinyupeng$ mysql --version
mysql Ver 14.14 Distrib 5.7.19, for macos10.12 (x86_64) using EditLine wrapper
YupengdeMacBook-Pro:~ yinyupeng$
You can try reseting the root password by running MySQL in Safe Mode.
Here are the steps:
Stop MySQL:
sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
sudo mysqld_safe --skip-grant-tables
This will be an ongoing command until the process is finished so open another shell/terminal window, and..
Log in without a password as root:
mysql -u root
Update root (and any other user's) password)
FLUSH PRIVILEGES;
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
\q
Restart MySQL in normal mode
sudo /usr/local/mysql/support-files/mysql.server start
Reference: https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/
Note: this is pretty much a copy-paste from the reference link. this is pretty standard reset procedure, but just documented better in that guide compared to mysql reference docs.
You can edit your mysql configuration file and add skip-grant-tables to the section [mysqld]
or
Start mysqld and send it to background
mysqld_safe --skip-grant-tables &
I had some tweaking for my server and unfortunately I can't log to phpmyadmin via whm anymore nore via ssh as I have access denied for root#localhost.
I tried to change my sql root password via whm but it give me the following error :
Unable to reset the MySQL root password.
The subprocess reported error number 1 when it ended.
Can anyone help me?
You'll have to check if you are able to login to mysql from a command prompt. Login to your server via SSH and issue a mysql. It should login to your mysql server.
If that doesn't work then do a cat /root/.my.cnf. There you should have the previous mysql root password. Copy that password and try this:
mysql -u root -p (then when prompted paste the password if you have copied earlier).
If you get an authentication failed message then that password is not the correct one and you have to manually change (you said you can't change it from WHM).
Do you use a local mysql server or a remote mysql server?
In order to change the mysql root password you have to stop the mysql service on the server and start it manually with skip grants option.
Depending on your CentOS version you have to options to stop the mysql service:
- CentOS 6.x - /etc/init.d/mysql stop
- CentOS 7.x - systemctl stop mysql
Then manually start the mysql service:
mysqld_safe --skip-grant-tables
Then issue the following:
mysql --user=root mysql
update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit;
Restart mysql and you should be able to login with your new password. You might also want to save it in /root/.my.cnf as well.
I hope it helps!
Bogdan, seems you have to issue one more command: use mysql;
And it's quite possible that issuing the command: update user set Password=PASSWORD('new-password') where user='root';
you will be errored that there is no field Password. It happens if you're running mysql server version 5.7+. In such case change command as follows:
use mysql;update user set authentication_string=PASSWORD('new-password') where user='root';
I using mariadb and my mysql root user lost all of privelages. so everything gives me the "access denied" now.
I tried to reinstall mysql but it's looks like the configure files not deleted.
how can I fix it when I can't access to mysql table and even can't have another fress install.
by the way I using ubuntu 16.04 and according to this question
How do I restore the MySQL root user's privileges?
I think I can't do any thing except remove mariadb completely with all configure files.
------------------update------------------
I have no problem with my password, the problem is my root user has no privelages.
please don't send solutions about changing password
Enter the following lines in your terminal.
Stop the MySQL Server.
sudo /etc/init.d/mysql stop
Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
Login to MySQL as root.
mysql -u root mysql
Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
I just installed mysql fresh on my computer. I never set any passwords nor have I set up any databases yet. Every command I try to enter into mysql is blocked because the system keeps prompting me for a password which I don't have. I've tried following many steps to reset the root password but often times when I enter a command such as:
./mysqld --skip-grant-tables --skip-networking
My terminal says something along the lines of (Errcode: 13 - Permission denied).
So can anyone suggest some file I should check or some commands I should try to set/reset the password?
Thank you
Not sure which steps you have taken this far based on your post, what OS you installed on (I am making an assumption it was on a linux distro), or whether it was from source or not but here are the steps you need to rest the root password:
How to reset the root password for mysql:
Stop mysql:
1. service mysql stop
Run mysql with skip grants to be able to login without any password
2. mysqld_safe --skip-grant-tables &
Login as root
3. mysql -u root
4. mysql commands:
mysql> use mysql;
mysql> update user set password=PASSWORD("YourPWHere") where User='root';
mysql> flush privileges;
mysql> quit
Stop mysql
5. service mysql stop
Start mysql normally:
6. service mysql start
Try to login using your new password:
7. mysql -u root -p
If that fails...I would just reinstall fresh...
During my salary instalation you should enter a password at some stage so long think you must have left the default password which is root if this doesn't work Uninstaller and reinstall paying special attention to every step