I've been try to install mysql on my Ubuntu 22, considering that i follow some code from my instructor like this o
sudo mysql
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
FLUSH PRIVILEGES;
quit
After that i try to re open mysql and showing error like this
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
what should i do?
Mysql -u - p
After that you please input your password
I have set a root password, but cannot authenticate with it. How can I reset this password?
~ mysql --version: mysql Ver 8.0.13 for osx10.14 on x86_64 (Homebrew)
I used these stackoverflow instructions to set a root password and queried the user table to verify the password.
I then tried mysql -u root -p and mysql -u root and got authentication errors.
Command: mysql -u root -p
Authentication error: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES). I am SURE I am using the correct password.
Command:mysql -u root
Authentication error: Error: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO).
That led me to this this stackoverflow question and attempted #Lahiru's solution, but got No such file or directory.
I found the Mysql documentation and performed the following: (as outlined in B.6.3.2.3 Resetting Root Password: Generic Instructions)
mysql.server start --skip-grant-tables
Mysql -u root
FLUSH PRIVILEGES
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
Then I got an error:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
Lastly, using the Mysql 8.0 documentation: 13.7.1.10 SET PASSWORD Syntax I tried:
mysql.server start --skip-grant-tables
SET PASSWORD FOR 'root'#'localhost' = '1111';
and get error: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
I can't try to do this while running the server out of safe mode because it doesn't accept the password I set.
Thanks in advance for any help.
I followed the instructions for Option 2 in the question ERROR 1698 (28000): Access denied for user 'root'#'localhost' and used superuser1 as my 'YOUR_SYSTEM_USER' (see code below).
$ sudo mysql -u root
mysql> USE mysql;
mysql> CREATE USER 'superuser1'#'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'superuser1'#'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='superuser1';
mysql> FLUSH PRIVILEGES;
mysql> exit;
$ service mysql restart
Now I get ERROR 1698 (28000): Access denied for user 'superuser1'#'localhost' when trying to log in to mysql as suggested in that answer, this error occurs even if I prepend sudo to the mysql command as shown below
hms011#hms011-OptiPlex-9010-AIO:~$ sudo mysql -u superuser1
[sudo] password for hms011:
ERROR 1698 (28000): Access denied for user 'superuser1'#'localhost'
hms011#hms011-OptiPlex-9010-AIO:~$
I'm using Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu) on Linux Mint 19
on a new desktop installation.
As a new mysql user I am being somewhat tentative when creating users until I become more familiar.
Should I perhaps change the plugin for my superuser1 to mysql_native_password?
The solution I followed suggested using no password (i.e. '') for the new user - will this affect any change of plugin?
I did look at the question MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES) and most other similar questions but could not see how any of the suggestions there would solve my issue - the suggested solution to my original issue did include using FLUSH PRIVILEGES which I followed (as I stated at the outset). My original issue (which remains) was ERROR 1698 (28000): Access denied for user 'root'#'localhost' Unlike some other users, it was not solved by using the recommended Option 2 in that thread. Hence I have raised my own issue, perhaps I was too succinct in my original description so have now included the code for option 2 solution mentioned above together with the resulting error when logging in.
In the absence of any assistance I have tried:
hms011#hms011-OptiPlex-9010-AIO:~$ sudo mysql -u root
[sudo] password for hms011:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant all privileges on *.* to 'superuser1'#'localhost' identified by 'toFFee8_&cHeese' with grant option;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
hms011#hms011-OptiPlex-9010-AIO:~$ mysql -u superuser -p
Enter password: {password was entered}
ERROR 1045 (28000): Access denied for user 'superuser'#'localhost' (using password: YES)
hms011#hms011-OptiPlex-9010-AIO:~$ sudo mysql -u superuser -p
Enter password: {password was entered}
ERROR 1045 (28000): Access denied for user 'superuser'#'localhost' (using password: YES)
So now I do get the ERROR 1045 (28000) but am none the wiser about why it (or the other errors) occurred.
Finally I went back to 'root' and re-granted all privileges to superuser1 I can now log in but without the password that was set up.
While this seems to be satisfactory I would prefer to know why it is so, in order to have confidence in what I have done
Solved
Eventually the whole problem seems to be solved after
Altering the plugin for both users to 'mysql_native_password'
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'auth_socket'
'auth_socket' was the existing plugin for root but for other Linux users it might be 'unix_socket'; and
- Setting a password for 'root' that does NOT include '&'
I forgot my MySQL password.
I'm using MySQL 5.7 on a Mac.
When I use mysql -u root I get the following error:
ERROR 1045 (28000): Access denied for user 'jan'#'localhost' (using
password: NO)
Things I've tried without success:
Setting the password:
Option 1:
mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET password=PASSWORD("NEWPASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
Getting the following error after mysql -u root:
ERROR 1045 (28000): Access denied for user 'jan'#'localhost' (using
password: YES)
Option 2
/usr/local/mysql/bin/mysqladmin -u root password NEW_PASSWORD_HERE
Change root password
cd /usr/local/mysql/bin/
./mysql -u root -p
> Enter password: [type old password invisibly]
use mysql;
update user set password=PASSWORD("NEW_PASSWORD_HERE") where User='root';
flush privileges;
quit
Getting the following error after ./mysql -u root -p:
ERROR 1045 (28000): Access denied for user 'jan'#'localhost' (using
password: NO)
Resetting the password according to the MySQL manual
sudo mysqld_safe --skip-grant-tables
When I use mysql I'm getting the following error:
ERROR 1045 (28000): Access denied for user
'jan'#'localhost' (using password: NO)
I also tried uninstalling MySQL from my Mac and reinstall it.
It's impossible for me to come any further without a password..
Somehow I lost root in mysql and I am trying to recover it.
I inserted root into the user table using the --skip-grant-tables option and then I ran
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
Then I started mysql regularly without --skip-grant-tables option
That’s what I see:
/usr/java/ep622_svn => mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.17 MySQL Community Server (GPL)
mysql> GRANT ALL ON *.* TO 'root'#'localhost';
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
This link helped:
https://dba.stackexchange.com/questions/97439/how-do-i-give-rootlocalhost-permission-to-grant-privileges-in-mysql
One needs to execute under running with --skip-grant-tables option:
UPDATE mysql.user SET
Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',
Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',
Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',
Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',
Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',
Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',
Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',
Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',
Create_tablespace_priv='Y'
WHERE user='root';
FLUSH PRIVILEGES;