This question already has answers here:
How to set root password to null
(21 answers)
Closed 9 years ago.
How can I change the root password to an empty one in MySql?
The following gives "Access denied for user 'root'#'localhost' (using password: YES)" error. I'm sure I've typed my password correct (it's only 123456)
mysqladmin -u root -p'123456' password ''
I've run this sql successfully but I can still access with my password 123456 and not with an empty one:
use mysql; update user set password=PASSWORD("") where User='root';
You should restart the MySQL server or run the following command:
FLUSH PRIVILEGES;
MySQL doesn't immediately "see" the changes you make to the tables containing user account data, hence the need for this additional step.
You need to FLUSH PRIVILEGES.
Related
Well, I'm using Ubuntu 20.04 and I have installed MySQL some months ago. Actually MySQL version is 8.0.30.
I'm trying to get in the mysql console, but it gives me that neither root nor my personal user have permissions on MySQL.
What I've already tried:
skip-grant-tables => One of the solutions was putting this option in one of the MySQL configuration files, and then alter the root password. but when I try to change the root password, it gives me that I'm using the skip-grant-tables option. After trying this, and of course, using flush privileges and restarting the service after changing it, I get:
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'#'localhost'
alter user => I tried many commands with alter user like:
alter user 'root'#'localhost' identified by 'My_password';
alter user 'root'#'localhost' identified with native_mysql_password by 'My_password';
set password for 'root'#'localhost' = PASSWORD('My_password');
But all theses commands give the error ERROR 1396 (HY000): Operation ALTER USER failed for 'root'#'localhost'.
Put the right authentication_string => Yes, I had checked this column to the root user, and it still giving me the same thing:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
No success at all. The last one even gives me a syntax error. But all this attempts gave me some information:
debian.conf => I did a cat in this file, and I found out that root user is not in there, even if it's in the Users table inside mysql database. But I can access mysql console with debian-sys-maint, using the password given in the file.
Permissions => I doesn't have any permissions with root.
root password => I have set the authentication_string to the root user inside users table to a very strong password, and even using it, I does not have permissions to enter mysql console.
Password validation => I have changed the global variables of password validation so I can change my password to a weak one. But when I restarted the MySQL service, it went back to the default configurations. It bothers me, but I can get along with it.
So what I'm looking for is: how can I give permissions to my root user access MySQL console? Should I recreate root user? Or is there another way to fix this?
EDIT1: PASSWORD function does not work for some reason.
EDIT2: I'm not able to create a root user. It gives me an error saying that I don't have permission to do so. It looks like mysql is not recognizing 'root' as a user. When I try "GRANT ALL" to 'root', it says that I don't have permission to create it, but it is already in the users table.
This question already has answers here:
How to reset mysql root password?
(8 answers)
Closed 4 years ago.
When I try to connect the MySQL Server by command:
mysql -u root -p
I get error "Access denied". I'm sure that the password is right.
When I use the
mysqld --defaults-files "xxx\my.ini" --console --skip-grant-tables
option, I can access in, but when I quit this, access is denied again.
How could I sovle it?
You can reset the root password.
For MySQL 5.7.6 and later:
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
This can be dangerous, read the full official instructions before: How to Reset the Root Password?
Try Resetting the Root Password: Generic Instructions
Restart mysql with the --skip-grant-tables option
In the mysql client : FLUSH PRIVILEGES;
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
Having trouble setting the password on the command line for MYSQL. My original installation from homebrew was successful and I was able to access the database by entering mysql. However when I am setting up the new password it will not recognize it. I know that I have been typing my new password and confirming my new password correctly so I don't think it an error like that.
Code:
Fareedahs-MacBook-Pro:~ fareedahjames$ mysqladmin password
New password:
Confirm new password:
mysqladmin: unable to change password; error: 'Can't find any matching row in the user table'
I even tried entering the password incorrectly just to test the error message so when the password i have typed match it is not setting the password
code:
Fareedahs-MacBook-Pro:~ fareedahjames$ mysqladmin password
New password:
Confirm new password:
mysqladmin: Passwords don't match
I read on another post about using
SET PASSWORD FOR 'root'#'127.0.0.1' = password('cangetin');
but it did not work
I tried running that in mysql and got
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
I am at a loss
It seems you didn't have the grant permission..
check the entries in your mysql.user table and paste here if possible.
Thanks
Changing MySQL root user password using mysql command
This is an another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update or change the password using the following method for user called root:
Login to mysql server, type the following command at shell prompt:
$ mysql -u root -p
Use mysql database (type command at mysql> prompt):
mysql> use mysql;
Change password for user root, enter:
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='root';
Finally, reload the privileges:
mysql> flush privileges;
mysql> quit
This question already has answers here:
Create new user in MySQL and give it full access to one database
(9 answers)
Closed 2 months ago.
How do I create a new MySQL user in XAMPP? Also, can I delete the existing “root” user?
It's too late but I'm sure my answer will help the community.
To create a new mysql user in XAMPP you need to type the following commands:
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'username'#'localhost' IDENTIFIED BY 'password';
\q
This command grants the user all permissions.For more information about setting MySQL database permissions, please visit https://dev.mysql.com/doc/refman/5.5/en/grant.html.
To delete MySql user definitively you should run this command
DELETE FROM mysql.user
WHERE user = 'root'
AND host = 'localhost';
Hope that it's helpful.
XAMPP
sudo /opt/lampp/bin/mysql -u root -p
Enter Your Super Secret Password
CREATE USER 'UserName'#'localhost' IDENTIFIED BY 'UR#Secret#Password';
GRANT ALL PRIVILEGES ON * . * TO 'UserName'#'localhost';
FLUSH PRIVILEGES;
Native MySQL Client (Not XAMPP / LAMPP)
sudo mysql -u root -p
Enter Your Super Secret Password
CREATE USER 'UserName'#'localhost' IDENTIFIED BY 'UR#Secret#Password';
GRANT ALL PRIVILEGES ON * . * TO 'UserName'#'localhost';
FLUSH PRIVILEGES;
For me below configuration worked. Its for LAMPP:
-Create a new database named "dvwa" from http://localhost/phpmyadmin/index.php.
-And then inside DWVA nano config.inc.php file. Make "db_password field" empty. (ex. '').
-restart the apache as well as mysql from xampp
This question already has answers here:
How to change MySQL root password to default?
(2 answers)
Closed 7 years ago.
I installed MySQL, and the installation requires a password. I didn't want to enter one, but I had to to click "Next" and finish the installation.
So, I tried to change it.
In the cmd prompt:
C:\>mysql -u root -p
Enter password: **
mysql> use mysql;
Database changed
mysql> select `password` from `user` where `user` = 'root';
That returns an empty password field. But when I do mysql -u root I get the access denied error, and then I do mysql -u root -p and it asks for a password, I press enter, and I get denied access. So I repeat what's in the code block above, and the same thing happens.
According to MySQL's documentation on How to Reset the Root Password:
UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root';
FLUSH PRIVILEGES;
Try this
In your command prompt,
Type the following :
mysqladmin -u root (assuming that ur username is "root")
Hit enter button, then it will show you commands to execute some stuffs.
for password change
Type the following ;
mysqladmin -u root password
It will then ask for new password
Enter ur new password , that is, the password you wish to use. Hit enter, it will request it again. Enter it and hit enter.
That is it, your password is changed
Now you can check the status
Type:
mysqladmin -u root -p status
It says, enter password ,
Use your new password
I hope it helps