I found a strange mysql behaviour I am struggling to explain
[vagrant#Subs ~]$ mysql -u root12 subdb
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'subdb'
It uses empty string '' as the user name in the error message even though I explicitly supplied root12. If I provide the right username it connects with no problems so I suspect it is just the way mysql reports the error.
Is this a bug or undocumented feature?
[vagrant#Subs ~]$ mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
EDIT
People seem to be confused by the wording of this question. I am using root12 as the username, not the password. I am also saying mysql there is no password for root12. Furthermore, root12 user does not even exist. So it is a clear authentication failure. My question is why instad of saying
ERROR 1044 (42000): Access denied for user 'root12'#'localhost' to database 'subdb'
it says
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'subdb'
EDIT
Running CentOS6.5, mysql 5.1.73 here. testuser user does not originally exist
[vagrant#Subs ~]$ mysql -u testuser subdb
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'subdb'
[vagrant#Subs ~]$ mysql -u root
...
mysql> CREATE USER 'testuser'#'localhost' IDENTIFIED BY 'testpassword';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[vagrant#Subs ~]$ mysql -u testuser subdb
ERROR 1045 (28000): Access denied for user 'testuser'#'localhost' (using password: NO)
It's clear from this output that MySQL (seems like only this version) is leaking info whether the username exists or not. If it does not exist the error message resets the username to empty string. If it does, mysql keeps the username intact
try as per below-
mysql -u root12 -p
It will ask you password and you need to supply root12 password.
but if root12 is password of root user then use below command-
mysql -u root -proot12
Related
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 m trying to create new database through mysql or ssh but on both m getting error
mysql : CREATE DATABASE porto;
Error : Access denied for user 'root'#'localhost' to database 'porto' on ssh : ERROR 1044 (42000): Access denied for user 'root'#'localhost' to database 'porto'
mysql> CREATE USER 'testuser'#'localhost' IDENTIFIED BY 'ecomaddon#42';
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
mysql> SELECT User,Host From mysql.user;
ERROR 1142 (42000): SELECT command denied to user 'root'#'localhost' for table 'user'
Its problem of privilege but don't know how give root user all privilege ai had try all methods but got nothing.
You can try to access as root
mysql -h 127.0.0.1 -P 3306 -u root -p
If it still does not work follow this guide
https://www.a2hosting.com/kb/developer-corner/mysql/managing-mysql-databases-and-users-from-the-command-line
you may be login as root but the root#localhost is not allowed for the actions you are executing.
mysql>CREATE USER 'root'#'localhost' IDENTIFIED BY 'enter_your_password_here';
mysql>exit
then try logging-in again
I think it's rights issue & It can be resolved by re configuring again. Here's a steps to reconfigure it.
Stop the current MySQL server instance:
sudo service mysql stop
Use dpkg to re-run the configuration process that MySQL goes through on first installation. You will again be asked to set a root password.
sudo dpkg-reconfigure mysql-server-5.5
Thanks for reply to all
i had solve i
1. first login to new user.
2. give access all to that users by update command .
3. drop root user and rename second user to root.
main problem was : when we create root it didn't give grant_priv field access users .
I ran MySQL with the Terminal with the following command.
mysql -u root
Then I tried to execute use mysql;, but it did not go properly but showed an unexpected message as follows.
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
Why do you think it's happening? Someone please help me..
Your login credentials are wrong. Did you create a password while installing MySQL?
try mysql -u root -p and enter the password in the prompt to log in.
If you've lost your password, try resetting it. View this answer to reset password.
I have a Linux EC2 instance which has MySQL server installed on it.
I can login with MySQL root with this command:
mysql -u root -p
For some reasons I created a user guest using following commands:
CREATE USER 'guest'#'%' IDENTIFIED BY 'passpass';
GRANT ALL PRIVILEGES ON * . * TO 'guest'#'%';
FLUSH PRIVILEGES;
Then I exit from root user and try to login with guest user:
mysql -u guest -p
entered the correct password and got this error:
ERROR 1045 (28000): Access denied for user 'guest'#'localhost' (using password: YES)
I even checked out for the anonymous user .
mysql> SELECT User, Host, Password FROM mysql.user WHERE User='';
Empty set (0.00 sec)
Kindly help. I am not able to connect to MySQL using guest user credentials
MYSQL AWS LINUX EC2 INSTANCE
I was trying to access mysql in AWS linux EC2 instance, but was getting the error:- Error: Access denied for user 'root'#'localhost'. After lot of searching I got the solution which worked for me.
So for mysql community server, the default password is randomly generated whenn you install.
Check /var/log/mysqld.log file, write vim /var/log/mysqld.log in terminal and search for the keyword "temporary password"- you will get the password.
Few configurations are required for mysql- sudo /usr/bin/mysql_secure_installation
it will ask for password then enter the "temporary password" collected earlier. and in the proceding steps question will be asked over there new password could be easily set. then can proceed with
mysql -u root -p.
try by Run the command
grant all on . to 'guest'#'%' identified by 'passpass';
flush privileges;
Thanks
EDIT- Turns out to be a silly question. The solution:
mysql -u root Don't put a -p as there is no password for fresh installs of MySQL root.
Original Question:
Autoparts just came out recently on nitrous: http://blog.nitrous.io/2013/09/18/introducing-autoparts-for-nitrous-io.html
and I ran the command $ parts install mysql to install mySQL...works great!
Now, how do I access mysql to setup a root user or other users?
mysql> CREATE DATABASE django_db;
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'django_db'
mysql> GRANT ALL ON django_db.* TO 'djangouser'#'localhost' IDENTIFIED BY 'mypassword';
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'django_db'
I don't know how to access mysql -u root -p because I don't know the root password, so I just used mysql to access the mysql from the terminal.
My end goal is to have the mysql setup on my box for a development and testing for my django web application.