Accessing MySQL with Toad via SSH - mysql

I'm giving Toad a try for use with my MySQL db, but I cannot seem to connect (Linux-based server with MySQL database) remotely using Toad. After entering the right credentials for both SSH login and the database login, I still get this:
'Access denied for user 'wlaprise'#'166.203.5.139' (using password: YES)'
I can however successfully login remotely using SSH and MYSQL commands directly from the command line using the same host and credentials, so I believe the credentials and firewall settings are not the problem. The username is the same for both SSH and the db (not the smartest, I know), so I even tried reversing the password entries in case I had the credentials switched. No difference.
I looked through Toad's 'Connection Properties' to see if it was encrypting my credentials somehow which could explain the 'Access denied' error, but didn't see anything.
This has to be basic, but I don't see what I'm missing? Ideas? Thanks.

When you are using shell command line , then you are connecting from localhost,
thus effective permissions are 'wlaprise'#'localhost'
What you can do is to grant permissions to same user, but from different location/IP:
GRANT ALL PRIVILEGES ON *.* TO 'wlaprise'#'166.203.5.139'
IDENTIFIED BY PASSWORD 'mypassword';
or
GRANT ALL PRIVILEGES ON *.* TO 'wlaprise'#'%'
IDENTIFIED BY PASSWORD 'mypassword';

Related

mysql not able to establish remote connection

Could not able to connect to the remote mysql server using mysql workbench or direct command line.
When trying it resolves different hostname
When trying directly through command line
mysql --host=10.37.1.92 --port=3306 --user=root --password=password
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'#'myaapvm.local' (using password: YES)
Tried, with password and without password, no luck.
I tried to connect to 10.37.1.92 server but my mysql client try to connect to different server. The only way I can try now is directly login to the machine and do the change in my DB. I have disabled firewall in my mysql DB. Does anyone faced this issue please help.
This server running with maria DB installation.
By default root is not allowed to access the database by using a remote connection. I recommend that you create a new user that will be used for remote connections. You can do that by using the following SQL commands:
CREATE USER 'myuser'#'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'#'%' IDENTIFIED BY 'mypass';
GRANT ALL ON *.* TO 'myuser'#'localhost';
GRANT ALL ON *.* TO 'myuser'#'%';
FLUSH PRIVILEGES;
You also need to modify your my.cnf if you didn't do that already.
#Replace xxx with your IP Address
bind-address = xxx.xxx.xxx.xxx

Can't access MySQL on LAN server

MySql is installed on a Ubuntu server.
I am running Windows 8.
Logging in through Putty. I can log in to database with both root and webadmin user accounts.
I can also log in through my browser, using <server ip address>/phpmyadmin
My problem is when I try to use command line to log in. I am trying that approach because I am developing a webpage to access the database on that server. It fails to connect, so I thought if command line works, the webpage will also work.
commandline:
mysql -u webadmin -p
or
mysql -u root -p
error 1045 (28000): access denied for user 'webadmin'#'localhost'
(using password: yes)
I added an iptables entry to allow mysql and that didn't work.
Also, the firewall on server is inactive.
You need to grant access to the database. You can read the documentation here: https://dev.mysql.com/doc/refman/5.1/en/grant.html
You can run the following (but be careful as it will leave your DB open)
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
That will allow root to connect from any IP and do any operations to the DB. If that still doesn't work, you might also need to run the following before the 2 lines above
CREATE USER 'root'#'%' IDENTIFIED BY PASSWORD '[your password]';

Access denied for user 'user'#'host' (using password: YES)

I have a created user in my MySQL database:
CREATE USER 'user'#'host' IDENTIFIED BY 'password';
I have granted that user full privileges:
GRANT ALL ON *.* to 'user'#'host';
Echoing the grant:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'host' IDENTIFIED BY PASSWORD '*03FFC888F82E921D8CA360925A8F443CF326DE89'
I can connect from MySQL workbench using this login credential w/o any issues and execute queries. And it's running on the same machine the web application is running on. MySQL instance is running on another computer in the same local network.
However, when I try to use the same credentials from my web application running in Tomcat7 under Eclipse I receive the error. Please advise.
Note: As of last night, the web application was able to connect just fine. With nothing changing (that I am aware of - I am only one working on this), this morning I could not connect.
RESOLVED:
I added the user with grants using the IP address for the host for the local machine.
I am not sure what changed on the server, but now I am able to connect again.
Would someone possibly be able to explain this change, and with it why I am now required to use the IP address when previously the local host name was sufficient?
Make sure you are using the appropriate hostname, and you're accessing from that host, the user can't connect from another host.
To give permission you must put the password unencrypted.
Example
GRANT ALL PRIVILEGES ON test. * TO 'root' # 'localhost'
IDENTIFIED BY 'goodsecret';
Also must be the same password when you create the user.
Here How adding users to MySQL
Note: For more information on GRANT here is the documentation.
Hope this helps

Can't connect as admin with MySQL Workbench

I've a CentOS 5 Plesk server.
I have an updated version of phpMyAdmin in a public folder and if I try to login with my admin details (the root user of the entire MySQL server) everything works fine.
If I try to login with the same user using MySQL Workbench it says:
Failed to Connecto to MySQL at <myip>:3306 with user admin
Access denied for user
'admin'#'<myisphost>.fastwebnet.it' (using password: YES)
I've tried other users and they works if I use the old authentication protocol. So I've tried with this option but the error is the same.
Connecting to MySQL from SSH terminal everything works fine, looks like the problem is only with Workbench...
Any help?
First variant:
Looks like your admin acount has been limited to access only from localhost.
Login to MySQL using mysql command from ssh (using your root credentials) and run this command:
GRANT ALL PRIVILEGES ON *.* TO 'admin'#'<myisphost>.fastwebnet.it' WITH GRANT OPTION;
This will allow you to connect from your host (<myisphost>.fastwebnet.it).
To check your access privileges:
SHOW GRANTS;
If you'll have something like this:
GRANT ALL PRIVILEGES ON *.* TO 'admin'#'localhost' IDENTIFIED BY PASSWORD '...'
than you have access only from localhost (machine where MySQL server is running on).
also you can check privileges using this command:
select user,host from mysql.user;
Second variant:
Second one variant is to use ssh-tunnel.
In MySQL Workbench when creating new connection select
connection method as "Standart TCP/IP over SSH" option.
Fill in your SSH/MySQL credintials. Please note to use your MySQL access options as for localhost.
Something like this:
In my case, I just closed all the current tabs in Workbench and logged in again.

Unable to connect mysql using ip address

I try to connect my db using host address as my ip address 203.199.209.**,but not able to connect db.if i try to connect my db using host address as localhost it connected successfully.
How to solve this issue?
MySQL grants access based on which host you are connecting from.
Run this command as root:
SELECT user, host FROM mysql.user;
These are the users which exist on your server. Notice the host column.
In short, a user is defined as both a user name (user) and a point of connection (host). When you access your server as localhost, you actually login as some_user#localhost. On the other hand, when you access the sever via its IP address, you actually login as some_user#your.ip.address.here. I guess the latter does not exist on your server.
You may want to create a new user such as some_user#your.ip.address.here or some_user#% (the percent sign is a wildcard; here, it means "any host"):
CREATE USER 'some_user'#'your.ip.address.here' IDENTIFIED BY 'your_password';
GRANT ALL ON your_database.* to 'some_user'#'your.ip.address.here';
If you wish to dig further, see this manual page for more details about MySQL access control, and this page for the CREATE USER syntax.
[edit]
Obviously, as suggested by others, you first need to make sure your server listens to this IP address (203.199.209.**). But if this were not already the case, you should get the following error:
ERROR 2003 (HY000): Can't connect to MySQL server on '203.199.209.**' (111)
The error you are getting definitely indicates a permission issue.
For mysql-5.7.15-winx64 (Windows Version), login as "root" user and run the following queries in MYSQL:
CREATE USER 'user'#'localhost' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON *.* TO 'user'#'localhost' WITH GRANT OPTION;
CREATE USER 'user'#'%' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON *.* TO 'user'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
and then Re-start your MYSQL DB.
For this version of MYSQL DB no changes are required in "my-default.ini" located in the same location as "bin" folder.