Change password in root and error in accessing localhost/phpmyadmin - mysql

I tried to change password in my database but after i changed it right away, I got an error saying
mysqli_real_connect(): (HY000/1045): Access denied for user
'root'#'localhost' (using password: NO)
and
phpMyAdmin tried to connect to the MySQL server, and the server
rejected the connection. You should check the host, username and
password in your configuration and make sure that they correspond to
the information given by the administrator of the MySQL server.
How to fix this? Do i need to configure something about the connection and where can I fix it?

Do you able to connect mysql in command line.
#mysql -u root -p
then provide the password to access mysql command line.
if Yes, then please make sure that you given the correct information while installing the phpmyadmin.

Related

Unable to connect to MySQL instance after installing

I'm setting up a MySQL database following this tutorial. I installed it and successfully initialized an instance with a root password, but I am having trouble connecting to the instance via command line. When I click on the 'mysql' executable under bin, I get this message
ERROR 1045 (28000): Access denied for user 'hunter'#'localhost' (using password: NO)
and if I try to enter
> mysql -u root -p
in the terminal I get this message
-bash: mysql: Permission denied
It says in the instructions that I should be getting prompted to enter the password for the database, but for some reason it won't let me.
I would suggest first off to try a mysql workbench. You can download it at https://dev.mysql.com/downloads/workbench/ .
It seems that calling mysql from bash is causing issues for you. If you are using a *Nix environment, it could be a permissions issue and you need to set the correct permissions on the mysql binary. However, usually a correct installation should have already done that. See: https://askubuntu.com/questions/229589/how-to-make-a-file-e-g-a-sh-script-executable-so-it-can-be-run-from-a-termi
Secondly, you should use the username root . hunter is not default username.
From the mysql documentation:
How to Reset the Root Password
If you have never assigned a root password for MySQL, the server does not require a password at all for connecting as root. However, this is insecure. For instructions on assigning a password, see Section 2.10.4, “Securing the Initial MySQL Account”.
Reference:
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html

I am trying to access my mysql server from the command line by typing in this: mysql -u root -p

I am trying to access my MySQL server from the command prompt. I typed in this command:
c:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
Then I entered my password when prompted and got this error message:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I'm not too experienced with MySQL or the command line interface so I'm not sure what this error message means. I've tried watching some youtube videos on different ways to do this but I keep on getting the same error. Any help on this would be appreciated. Thanks!
It means your attempt to get authenticated failed.
That is probably because you are using the wrong password for the "root" user in your mysql instance. When you say "entered my password" do you mean you entered the password you set for root when you installed mysql, or do you mean the password you have for your user account on that computer?
It needs to be the mysql password for the user in mysql named "root". Note that this has nothing to do with any users in the operating system that is running this instance of mysql.
Check your choice of password and make sure you use the mysql "root" user password. Or if you have the credentials (that is, the user name and password) for a different user in the mysql instance, use those instead.

MySQL not working with Laravel

This may be a noob question.
But I have tried everything, purging and reinstalling trying to reconfigure and the works.
For some reason my root that was set without a password on localhost is denying me access
I have tried to reset the root password using the command line but to no avail.
Does anybody know how to get this error to be fixed?
ERROR 1045 (28000): Access denied for user 'devin'#'localhost' (using password: NO)
I am using linux and ubuntu
Even though you set your root user to login without a password, this does not mean that user devin has been configured to login without a password.
Edit your .my.cnf file:
vi ~/.my.cnf
In the file which you see, hard code the password for user devin, save the file, then exit.
[client]
user=devin
password=your_password_goes_here
Then restart MySQL and devin should be able to login without using a password.
The following command should work to connect you to a database called my_db:
mysql --user=devin my_db

error #1045 - Access denied for user 'root'#'localhost' in phpmyadmin

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Even after uninstalling wamp and then reinstalling it's showing the same error.
You can try connecting via the command-line interface using the username and password you expect; if that doesn't work then I presume you'll need to reset your password.
The MySQL manual has detailed instructions for resetting a lost root password.
Generically, those instructions are:
Start MySQL with the --skip-grant-tables option
Connect via the command line client with mysql (or the Start Menu program that corresponds to the command line client).
Run FLUSH PRIVILEGES to load the privilege table
Reset the password with a command like SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass'); adjusting the username, host, and password as needed.
Stop and re-start the MySQL server.

Access denied for user 'root'#'localhost' (using password: YES) EVEN when the Password works on PhpMyAdmin

I have an issue with accessing MySQL using root and password.
I am trying to connect the Server using PuTTY SSH using
> mysql u root -p
For an unknown reason I can NOT access the Database and I am getting rejected with the following ERROR:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
The weird thing is that I am using the same password with PhpMyAdmin using Web and I can access everything. I need to run a script that will allow the SQL server
root#localhost user
run the query over the LAN and not the web.
Therefore I need the user to connect using command line SSH or something like that.
How can I fix that issue? the user rott and password WORKS just fine through PhpMyAdmin and not through SSH PuTTY, Why?
Is there something I need to do in order to fix this? I have been working with the Database for 2 years now using the web interface. Now I need to have it working using SSH (22).
Please assist.
thanks in advance.
Arye
It sounds like you need to update the your password for root on MySQL.
Check here: MySQL - ERROR 1045 - Access denied
Thank you all for your help. I have managed to overcome the issue: (see below)
That was FIXED Only when I changed from old password to new. in my.cnf file I have removed the flag for old_password=1 and Restart the service of MySQL.
Then I have created a NEW password (using the old one I had) and it was created with 41 (NEW) Hash length and not 16 (OLD)..
Then I did flush privileges as you recommended - and IT WORKS.
Thank You!
> mysql -h your_host_name -P your_port_number -u your_user_name -p
try with hostname option it should work!
Ubuntu 18.04 running MySQL 5.7.28 creates a file /etc/mysql/debian.cnf. It contains some credentials and other settings. So, this debian-sys-maint user is by default a root equivalent. It is used by certain maintenance scripts on Debian systems, and as a side-effect, allows users with root access on the box to view the plaintext password in /etc/mysql/debian.cnf. If your SSH using a client fails after a fresh install through root try using the credentials set in this file.