Another 1045 : Access denied for user 'someone'#'localhost' (using password: YES) - mysql

As lot of dummies, I cannot connect to MySQL server with user.
This is settings of my USER in DB mysql table user
Host: %
User: someone
Password: mypassword
Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Create_user_priv: Y
max_questions, max_updates, max_connection, max_user_connections: 0
Connection
Im connecting via localhost console OR phpMyAdmin installed on this machine.
MySQL Server
Information from phpMyAdmin: Server: Localhost via UNIX socket | Server version: 5.0.70-log | Protocol version: 10
When mysql server is running as mysqld_safe --skip-grant-tables & then I can connect to server as any user.
When mysql server is running normally as /etc/init.d/mysqld start then I cannot an I have error
1045 : Access denied for user 'someone'#'localhost' (using password: YES)
I was spending hours to find solution in google and mysql documentation but without result. Probably it will be some essential settings. Hope you will give me some suggestion. Thanks a lot.

You probably need to reset the password for the someone user. It happens often.
Try to start your local server with no password check:
mysqld_safe --skip-grant-tables
And then
set password for 'someone'#'localhost' password('new fancy password')
(notice the '')
See more info in the docs: http://dev.mysql.com/doc/refman/5.0/en/set-password.html
This answer might also help
MySQL - ERROR 1045 - Access denied

Related

Recover my root user's DBA privileges on MariaDB

I accidentally removed the DBA privileges of my only user from mariadb and now I can't use my bank and I was also unable to restore the privileges using the Linux SHELL CentOS 7.
Command I tried:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
return:
#1045 - Access denied for user 'root'#'localhost' (using password: YES)
Has anyone ever experienced this?
It's a wrong assumption that the wildcard for hostname also includes localhost, so an attempt to connect via socket (localhost) will fail:
mysql> create user 'foo'#'%' identified by 'bar';
Query OK, 0 rows affected (0,01 sec)
$mysql -ufoo -pbar -e"select current_user"
ERROR 1045 (28000): Access denied for user 'foo'#'localhost' (using password: YES)
When creating the user with localhost, everything works as expected:
mysql> create user 'foo'#'localhost' identified by 'bar';
Query OK, 0 rows affected (0,01 sec)
$ mysql -ufoo -pbar -e"select current_user\G"
*************************** 1. row ***************************
current_user: foo#localhost
Also beginning with MariaDB Server 10.4 (Posix platforms) the default authentication method for the root user (when connecting via localhost) happens via unix_socket plugin. This allows the root#localhost user to login without a password via the local Unix socket file defined by the socket system variable, as long as the login is attempted from a process owned by the operating system root user account:
mysql -e"show grants for root#localhost\G"
*************************** 1. row ***************************
Grants for root#localhost: GRANT ALL PRIVILEGES ON *.* TO `root`#`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket WITH GRANT OPTION
So a normal login as root will fail:
georg#mozart:~/mariadb$ mysql -uroot -e"select current_user()\G"
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
While running as root (sudo) login works as expected:
georg#mozart:~/mariadb$ sudo mysql -uroot -e"select current_user()\G"
*************************** 1. row ***************************
current_user(): root#localhost
Stop MariaDb server
sudo systemctl stop mariadb
Restart DB without permission checking - more
sudo mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root enter password
reload the grant tables
Mariadb[MYSQL]> FLUSH PRIVILEGES
insert into user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, max_updates, max_connections, max_user_connections)
values('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','','0','0','0','0');
Then restart database
sudo systemctl start mariadb
I hope this works for you. it did work for me.
You can explore answers on Grant privileges on MariaDB

I can't connect to MySQL server in any way (on Windows)

My problem is below:
C:\Users\ordek> mysql
ERROR 1045 (28000): Access denied for user 'ODBC'#'localhost' (using
password: NO)
C:\Users\ordek>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: NO)
C:\Users\ordek>mysql -u root -p
Enter password: ****
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: YES)
I tried lots of solutions before asking here. I've even tried reinstalling MySQL but surprisingly this problem still exists. In Workbench I can't connect to any connection. I always login to the MySQL server as superuser and subsequent attempts to change privileges didn't work because I can't log into MySQL in the usual ways.
In Workbench it doesn't matter which user: root or not, you'll get this message.
[Window Title]
MySQL Workbench
[Main Instruction]
Cannot Connect to Database Server
[Content]
Your connection attempt failed for user 'user1' to the MySQL server at
127.0.0.1:3306:
Access denied for user 'user1'#'localhost' (using password: YES)
Please:
1 Check that MySQL is running on address 127.0.0.1
2 Check that MySQL is reachable on port 3306 (note: 3306 is the default,
but this can be changed)
3 Check the user user1 has rights to connect to 127.0.0.1 from your
address (MySQL rights define what clients can connect to the server and
from which machines)
4 Make sure you are both providing a password if needed and using the
correct password for 127.0.0.1 connecting from the host address you're
connecting from
In "test connection"(WORKBENCH) I always get this message:
[Window Title]
MySQL Workbench
[Main Instruction]
Failed to Connect to MySQL at 127.0.0.1:3306 with user user1
[Content]
Access denied for user 'user1'#'localhost' (using password: YES)
In my mind this is a problem with privileges, but I don't know what to do because I'm a beginner at MySQL. If you know how to overcome this problem, please let me know.
I believe you installed MySQL (windows) using .msi package. As it .msi allows you to do the installation step by step and you can set "root" password.
If you have root password, make sure MySQL services are started.
Control panel > services > Mysql
The user ordek seems unknown to mysql . Switch to root user and it will work .
If this is not possible , or the root password is unknown , re-install mysql , make a note of the root password for future use , create the ordek user and assign it the access rights it needs .

All users are having NO Privileges in phpMyAdmin

By mistake, I changed all the privileges of user 'root' in my MySQL Database. Not even a single privilege is having for that user. Now if I log in with another user I am able to access only one database. But I have nearly 25 databases created with 'root' user. If I want to access all other databases I need to GRANT Privileges for the root user again but all other users are not permitted to execute GRANT statement. So is there any way to grant permissions for the root user again. The all other Databases contained in my DB Server are very much important. So Please help in resolving this issue.
This is for XAMPP
Log in as root, then run the following MySQL commands:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost';
FLUSH PRIVILEGES;
If you get an error please try this:
Stop mysqld
Restart mysql with the --skip-grant-tables option.
Add the two options in the mysqld section of my.ini:
my.ini
[mysqld]
skip-grant-tables
skip-networking
and then run
Open command prompt windows >> Command prompt
net stop mysql (wait 10 seconds)
net start mysql
Connect to the mysqld server with just: mysql (i.e. no -p option,
and username may not be required).
Open command prompt windows >> Command prompt
Type cd C:\xampp\mysql\bin
Type mysql
Issue the following commands in the mysql client:
insert into user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, max_updates, max_connections, max_user_connections)
values('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','','0','0','0','0');
Reference: How can I restore the MySQL root user’s full privileges?

What is the relationship between local machine hostnames and MySQL hostnames?

I have Fedora 19 on my local machine and changed the default hostname to 'my.greathostname'.
So that means when I am using the terminal my prompt is:
[me#my ~]
I installed MariaDB.
I created a new user in MariaDB eg 'newuser#my.greathostname'.
When I try and login to MariaDB with 'mysql -u newuser -p' and enter password I get:
ERROR 1045 (28000): Access denied for user 'newuser'#'localhost' (using password: YES)
So, by default, it is trying to login to 'localhost' and not 'my.greathostname'.
Why is it trying to login to 'localhost' when the hostname of my local machine is 'my.greathostname'.
The reason I want to change the hostname in MariaDB is just to have a more 'custom' experience.

Ant couldn't connect to mysql (access denied), but mysql client could

I hava the next task in my ant file:
<target name="initdb">
<sql driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dtest"
userid="root" password="oksaoksaoksa" >
<classpath>
<pathelement path="./lib/mysql-connector-java-5.1.13-bin.jar"/>
</classpath>
<transaction src="./init.sql"/>
</sql>
</target>
When I run it, I see the error:
BUILD FAILED
/home/sbos/projects/texterra-tests/deploy.xml:43: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
However, I can login with such login and password with mysql client:
mysql -u root -p
Enter password: <oksaoksaoksa>
Welcome to the MySQL monitor. Commands end with ; or \g.
...
Why this happens? I've just installed mysql in ubuntu 10.10 if that matters
It happens because when you connect through localhost in the mysql client, it uses the unix socket to connect, which handles privileges a bit different, while ant connects to localhost through tcp/ip.
Try granting access to 127.0.0.1 (which is not the same as localhost as far as the mysql server is concerned)
grant all on initdb.* to 'root'#'127.0.0.1' identified by 'oksaoksaoksa';