MySQL not connecting with Command Prompt - mysql

I have one instance of mysql.
It is running at "C:\Program Files\MySQL\MySQL Server 5.5\bin\"
Now, when I try to connect using "heidisql" tool using user name as "root" and password as "eagle" then it connects properly and show the databases which I had created.
Now I open Command Prompt and go to the location where my MySQL service is running, Here I executed the same command but not working like shown below,
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot -peagle
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Also, now I closed all the mysql server and then typed
"C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql"
then it connects properly. I am not getting as all my mysql server is off then whom it is connecting to.
I am suspecting some where I have 2 instances of mysql running but I checked ControlPanel, Services running, No where I found any other service.
If any body faced such issue and solved, please suggest me solution.

There can be some root users on the same MySQL server which differ by host, for example - 'root'#'localhost', 'root'#'%', 'root'#'server'. All these users can have different passwords. Check it firstly, and specyfy -h or --host option in your command line.
Also, command line syntax is incorrect, it should be like this -
mysql -u root -peagle

Related

On Windows 10; ERROR 1045 (28000): Access denied for user 'personalUser'#'localhost' (using password: NO)

I have installed Xampp on windows 10 to create a simple app to understand how to use Laravel. I have the last version of Xampp. I configure PHP correctly (with path and so on), but I have a problem with MySQL.
I put the MySQL bin folder address in the user variables path (section in the system properties). In this way, my prompt command recognizes the mysql command. The problem arrives when I write this command: mysql -v. I tried a lot of things, but this Error remains:
ERROR 1045 (28000): Access denied for user 'personalUser'#'localhost' (using password: NO)
PS: personalUser is a generic name to indicate the name of my user.
I have tried to substitute the MariaDB with MySQL in the Xampp folder (I don't know why Xampp has the MariaDB version instead of MySQL). I redownload Xampp twice times. In the xampp folder, in the phpMyAdmin folder, in the file config.inc.php, I changed this command line:
$cfg['Servers'][$i]['password'] = ''; with $cfg['Servers'][$i]['password'] = 'NO';
I tried other things.
Based on the error message you are receiving, it seems that the issue is related to the authentication credentials for the MySQL server. The error message indicates that the user 'personalUser' is not allowed to access the MySQL server because they are not using a password.
To fix this issue, you can try the following steps:
Open the MySQL command-line client by running the mysql command in your terminal or command prompt.
When prompted for a password, enter the password for the user 'personalUser'.
If you do not know the password, you may need to reset it by following the steps in this MySQL documentation: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
Once you have successfully authenticated with the MySQL server, you can use the GRANT command to grant the 'personalUser' user access to the database you want to use. For example, to grant access to the 'mydatabase' database, you can use the following command:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'personalUser'#'localhost';
After granting the appropriate privileges to the user, you should be able to access the MySQL server and use it with Laravel.
If you continue to have issues, you may need to check the configuration of the MySQL server to make sure that it is set up to allow access from the user 'personalUser'. You can refer to the MySQL documentation for more information on how to configure user access: https://dev.mysql.com/doc/refman/8.0/en/adding-users.html

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

Why can't I connect to mysql with command line but can do that with DataGrip?

I got a username and password from others and has connected to that MySQL database for days with DataGrip. Today I used mysql command line to connect that database but I got an access denied error. I used the same command line to connect other database and it worked rather than this database.
I am curious that why DataGrip can connect to the database with username and password while command line can't. I've tried for tens of time so there should not be typo. PyMySQL and official Java connector can connect while offical C/C++ connector can't do that with that database. What is the setting that makes this happen?
The command line I use:
mysql -h 10.224.23.21 -u board -p
And the password is typed correctly.
The error message is
ERROR 1045 (28000): Access denied for user 'board'#'10.227.24.176:39300' (using password: Yes)
I have found the issue was caused by the new version connector tried to connect the old version of MySQL server. MySQL 8.0 uses caching_sha2_password as default. So if I want to connect the old version of MySQL, I need to change the plugin to mysql_native_password.

mysqldump on remote server to local machine: error: 1045: Access denied for user 'root'#'10.213.213.11'

I am running the command line as an administrator and trying to perform a MySQLdump to grab a backup of a table on a remote server. I would just go to the server and grab a back up there but I have over 100 different servers to grab a backup from. Here is what I have:
C:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.47>mysqldump -P3306 -h172.30.0.40 -u root -p apha polldistribution >test.sql
Enter password: **********
mysqldump: Got error: 1045: Access denied for user 'root'#'10.213.213.11' (using password: YES) when trying to connect
I have tried to grant all on my local machine as well as the remote machine. I have also logged into the remote database using the exact same password, and it can access fine it just wont work when performing a dump. And I tried to migrate through MySQL workbench but I get the same error message when prompted for a password.
Once I am able to get through one server I can make a program to loop through them all. Its just a problem connecting. Hopefully someone has some insight on this. All I really need is to be able to get my backup. Any help at all is appreciated.

SQL Access Denied

I'm working through tutorials in the book 'Cloning internet apps w/ Ruby.' I've made web apps before but they depended on sqlite and now I have to use mysql.
I've installed community server but when I try to create a database using the command line I'm receiving the error message listed above.
$ mysql
mysql> create database tinyclone;
Returns
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'p'
Notes:
The mysql command-line client flashes open and immediately closes, so I'm accessing it from the command prompt.
I've installed and uninstalled mysql several times in attempts to figure out this problem. In the latest install, I didn't set a password.
I'm aware that this line should probably be '$mysql -u <username> -p <password>' but I didn't set a password and I'm not sure what the username would be.
By default, the user is root
If you havn't set a password, use $ mysql -u root
The default MySQL username is 'root', try that without a password
The default username for MySQL is root, so you can try by
$ mysql -u root
by default it logs you with your Linux account. If you're logged as root on your Linux machine it will be OK just using $ mysql