MySQl log in issue when changing #localhost to IP address - mysql

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

Related

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.

Unable to connect to mysql remotely

I have a mysql database running on a VPS. I can ssh into the host and connect to mysql with no problems. I cannot connect to mysql remotely from my desktop. I have performed the following:
opened port 3306 on the firewall
added my local IP to the remote IPs accepted by mysql. This was done via CPanel
executed
GRANT ALL ON dbname.* TO username#'x.x.x.x' IDENTIFIED BY 'PASSWORD'
to tell mysql to let me connect from the specified address.
I execute the following from the command line on my desktop:
mysql -h x.x.x.x -u username -p
I get a password prompt which indicates I am past the firewall and mysql is responding. When I supply the password, it denies access:
ERROR 1045 (28000): Access denied for user 'username'#'x.x.x.x' (using password: YES)
Have I missed something?
The answer was given in the comments, so I will repeat it here to properly close the thread. alvits suspected that the remote user had not been created. It had been created but his comment prompted me to clean up the user table.
I deleted all remote users including loads that had been created by CPanel or migrated from another host. I then started from scratch doing create user and grant all and it works now.
Thanks!

Cannot log in to mysql using root

So I'm setting up mysql for the first time.
I read somewhere that I have to run this
mysql -u root -p
To log in as root, in order to be able to create tables/databases using the mysql command line.
When I run this, I get prompted for a password - I hit enter (I thought the default password was blank).
I get this error
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
What's going on?
If you have a fresh installation of MySql you should be able to issue the following command and it should allow your connection.
xyz#ubuntu$ mysql -u root mysql
You then should set the root password and then create a user with the correct level of access.
look HERE for help connecting.

mysql appends my domain to my username

I'm trying to access a mysql server remotely, I have all the login details but whenever I try to connect, it always adds my current IP or domain to the username, thus preventing me to login. Furthermore, I don't have terminal access to the server.
From the command line I try something like:
mysql -h example.com -u the_username -p
It returns with the error:
ERROR 1045 (28000): Access denied for user 'the_username'#'my_isp_address.com'
trying:
mysql -h example.com -u the_username#example.com -p
doesn't make a difference, it just returns:
ERROR 1045 (28000): Access denied for user 'the_username#example.com'#'my_isp_address.com'
How can I get through this?
That's how MySql works, you have to specify domain(or ip address) for your records.
If you want to use IP addresses, you will need to enable --skip-name-resolve poperty
More info here DNS Lookup Optimization and the Host Cache
Another option grant access for all hosts for user:
GRANT SELECT ON `db`.`table` TO 'user_name'#'%'
Use (%) sign.
But if you don't have access to server or DB, you will have to find server/db administrator, to configure it for you.

Can't Connect to LocalHost Mysql Server

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