Can't Connect to LocalHost Mysql Server - mysql

I recently installed mysql server and client, but I can't connect to the server. I get this message:
Access denied for user 'root'#'localhost' (using password: YES/NO)
Whatever I do i will always get the same message.
I tried commenting bind-address but still the same thing.

If you set up a password for the root user during installation, then start the mysql client with the -p option, mysql -u root -p, and it should prompt you for a password.
If there's no password set, leave the -p off and it should log right in.
If you've somehow forgotten what the root password is, you can fix it by following these instructions... http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

Related

Can't run mysql commands as root linux user

As linux root user:
root#local:~# mysql
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: NO)
I'm confused. Shouldn't the root user be able to run mysql without additional authentication? How do I fix this?
Your root account in MySql has a password. Try this
mysql -p
and enter the password you, or somebody set.
If that doesn't work try
mysql -h localhost -u root -p
It that doesn't work you'll need to reset your MySql root password. That's the topic of several tutorials on the 'toobz
If the MySQL root user has a password, using the default authentication plugin, then you must provide a password to connect, full stop. You can configure an account with no password, but that's a habit you should avoid.
You can provide a password by any of the following means:
Entering it interactively with the -p option
Entering it in plaintext in the commandline like -p<mypassword>
Storing it in plaintext in your ~/.my.cnf file in the [client] section (see https://dev.mysql.com/doc/refman/8.0/en/option-files.html)
Storing it in an obfuscated form in your ~/.mylogin.cnf file (see https://dev.mysql.com/doc/refman/8.0/en/mysql-config-editor.html).
There's also a way to provide a password through environment variables, but that's discouraged now because it's really not secure.
ALTER USER 'root'#'localhost' IDENTIFIED WITH auth_socket;

MySQl log in issue when changing #localhost to IP address

I created a user called 'test1' with all all the privileges, but I changed the host name to be my ip address instead of localhost. I was able to login and create a connection using MySQL WorkBench just fine. However I can not login using terminal because it adds #localhost by default each time I try to login. As you can see the below error, it is adding #'localhost' by default. Am I doing something wrong here? FYi, I am doing all the logging on my local machine and my password is correct since I use using workbench just as fine.
mysql -u 'test1'#'xxx.xxx.x.xx' -p (login command)
ERROR 1045 (28000): Access denied for user 'test1#xxx.xxx.x.xx'#'localhost' (using password: YES)
Here is the correct way of login command when one has a user with host name other than localhost.
mysql -h xxx.xxx.x.xx -u test1 -p

How to change MySQL root password via a file?

How do I change the MySQL root password in ubuntu server via a file?
The file may be any shell script or normal text file.
My try:
Normally the below command, in the terminal, changes the password for newly installed mysql.
mysqladmin -u root password 'newpass'
But while doing it via file it's showing the bellow error.
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
So can someone help me to do so.
Stop the MySQL Server: sudo /etc/init.d/mysql stop
Start the mysqld configuration: sudo mysqld --skip-grant-tables
Login to MySQL as root: mysql -u root mysql
Replace YOURNEWPASSWORD with your new password:
UPDATE
mysql.user
SET
Password = PASSWORD('YOURNEWPASSWORD')
WHERE
User = 'root';
FLUSH PRIVILEGES;
exit;
Note: This method is not regarded as the most secure way of resetting the password, however, it works.
If you have never assigned a root password for MySQL, the server does not require a password at all for connecting as root follow :
Resetting Permissions

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 access denied for user 'odbc'#'localhost' to database

I installed MySql5.5 and set password during installation but when I try to use mysql from windows command prompt, I have get the error:
access denied for user 'odbc'#'localhost' to database password = 'YES'
I would like to change it back into "root#localhost" as well as to reset the password but I can't log in mysql.
How do I login to mysql with root?
You're trying to use the mysql interactive shell? You can specify usernames at the command line:
c:\> mysql -u root -p
where
-u = specify username
-p = prompt for password
I fixed this by implementing a little hacky solution. Downloaded hxd (hex editor) and searched for 'ODBC' (there should only be one match) and just changed it to 'root'.
You are logging into mysql with a default no-rights user, you have to login as root if you want to do everything:
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql.exe -u root -p
Enter Password: *****
If you never specified a root password it should be blank, if you did, you have to remember what it was, or find out how to reset the root password.