JDBC MySQL Connection Error - mysql

I get the following error when trying to make a jdbc connection to a mysql database:
Attempting to connect to jdbc:mysql://localhost/castel castel castel
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'castel'#'%' to database 'castel'
I can connect to the database through the command line without a problem using the same credentials. I thought it might be a privilege issue so I ran:
GRANT ALL PRIVILEGES ON mysql.* TO 'castel'#'%'
Any help would be greatly appreciated.

OK the problem was completely unrelated to database configuration. It turns out my box had it's iptables configured to forward all traffic on port 3306 to another machine so I wasn't talking to the database that I thought was.

Related

ERROR 1045 (28000): Access denied for user 'root'#'localhost' (USING PASSWORD = NO) issue Freeradius server causing aborted connexion

Hi I'm trying to get a mariadb/freeradius/daloradius server up but i keep getting this log from systemctl -xe on my mariadb/mysql service, i came across that after figuring it was the sql connection that was problematic, freeradius shows me the same :
I'm getting frustrated, i ran across almost every config file, all should be in order but no this keeps happening, the radius server is trying to connect to my root sql user when i pointed to him in his config file that he should use the one i created especially for him and i can't manage to understand why, do mariadb needs the root credentials before even allowing it to connect to it ? I'm clueless please help.
This message tell you. that either the credentials in your config is not ok or that root user is not authorized to login.
Best practice is to take your mysql config and try to connect with the mysql command:
mysql -h yourconfigurationhost -u yourconfiguration user -p yourconfiguration password yourconfigurationdatabase
Be shure doing this with your application user.

Mysql not accepting connections from some sources

I have a MySQL server (v8.0) running on windows server 2016. I also have IIS running and PHPMyAdmin installed. In addition to this, I have a PHP web application which runs on the same server (under IIS) which accesses the MySQL database. Finally, I have several Python scripts which access the MySQL database.
Somehow, I have lost the ability to access the database from the Python scripts, but the web application still works and PHPMyAdmin can see and modify the database.
Even more strangely, I can no longer user MySQL Workbench to access the server from a PC on the local network, and PHPMyAdmin cannot access the users table of the mysql database. I can't change user details at all through PHPMyAdmin, I get the error:
Error in processing request
Error code: 500
Error text: Internal Server Error (rejected)
It seems that the connection to server has been lost.
MySQL Workbench gives me this error:
Your connection attempt failed for user 'user' to the MySQL server at SERVERADDRESS:PORT:
Access denied for user 'user'#'SERVERADDRESS' (using password: YES)
I have checked that the server can accept connections from remote computers by adding bind-address=0.0.0.0 to the my.ini file. I have also checked to ensure that 3306 is allowed through the firewall.
Any ideas on what could be causing this issue?
ADyson and MrApnea pointed me in the right direction.
The problem was caused by my main database user having the host reset from % to localhost, I'm not sure how this happened or when. As the app was running locally, this was not affected, but all other access was denied (including MySQL workbench). My root user is set to local only for security.
To fix this, I connected to the server via RDP and logged in to the console as the root user. I then ran these commands to see the error:
use mysql;
select host, user from user;
This showed me that the main user account had "localhost" in the host. I ran this command to update this user:
update user set host='%' where user='username' and host='localhost'; flush privileges;

User lost ability to connect from remote app server

Server version: 5.5.54-0ubuntu0.14.04.1 (Ubuntu)
I had an issue where a user lost the ability to connect to the mysql server from a remote application server.
user is created as 'user'#'%'
user has all privileges on the db in question
user connects remotely from a cron job and runs a daily report, connectivity just seems to have disappeared
failed: Access denied for user 'user'#'host' (using password: YES)
After confirming I could connect locally and remotely from a different server - on a whim, I issued flush privileges; this immediately resolved the problem.
I am trying to understand why - what event would have caused the lost connectivity? Really just trying to be able to explain it.
This problem has been resolved - ended up being a network issue that was contributing to intermittent connectivity issues - flush privileges, while appearing to resolve the problem actually was not part of the issue at all.
Thanks to everybody that took a look.

MYSQL Remote Connection Coda 2

I just bought Coda 2 and I want to try this feature about mysql database connection. I´m not able to connect. The error that appears is:
Unable to connect to host 1.2.3.4, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges,
or try increasing the connection timeout (currently 0 seconds).
MySQL said: Can't connect to MySQL server on '1.2.3.4' (60)
The error takes 60 seconds to appear. For easy answers, Il´l make an example:
Server IP: 1.2.3.4
MYSQL Username: root
MYSQL Password: 1234root
I use xampp on a windows server. How can I connect to the mysql database remotely? About the privileges, the account I use for root has all privileges. Thank you and have wonderful holidays.
You need to configure your mysql server to allow remote access to root, usually a very bad idea. Remote access is bad enough. You would need to permit remote access and grant the root user at your remote address access.
see Enable remote MySQL connection: ERROR 1045 (28000): Access denied for user
This is why people usually install something like phpMyAdmin to get this kind of access. Setting up a non root user is another choice.

Error No. 1045 : While trying to connect to MySql

I installed SQLYog Community edition for windows, a GUI tool for MySql. I had earlier installed MySql with XAMPP. Now when I am trying to connect , I see an error (as pointed):
What could be the reason, I am getting this ? How do I connect to MySql and start using this GUI tool ?
The message says access denied for suhail #localhost . These could be the issues :
The user suhail does not exist at locahost.
The password specified is wrong.
MySql Server is not started. If it is started the port number is not 3306.
These are some of the troubleshoot techniques.
Also follow the comments on your question.
I had exactly same error message, however, it is resolved by means of using admin password on my machine. The message I get is as follows:
Connection info
Connection successful!
MySQL version: 5.1.54-community
Then I clicked ok to continue. See if this works for you!
error 1045 is a common authentication error
The user should be allowed to connect from remote hosts.
It should be defined as 'suhail'#'%' and not 'suhail'#'localhost')
http://webyog.com/faq/content/23/18/en/error-no-1045-connection-denied.html
* User is not allowed to connect from the actual host. Note that MySQL by default only allows connection from 'localhost'. To specify from where a user may connect SQL wildcards (% and _) can be used. Simply 'someuser#%' means that user 'someuser' may connect from everywhere.
I too was having the same problem, but it was solved by giving.. username as- root.
So. try by giving
username: root.
Go to mysql Workbench >> Users and privileges >>
Select user in user accounts tab, then on right side open schema privileges tab >> there you have to give required permissions.
If not work,
open a 3306 port in windows firewall.
Check whether the port is already in use or not. 3306 port is for Mysql server. So check whether it is being used or not. if it is used then we can kill that process and can try again to connect to the same port.
Please try to put the 127.0.0.1 instead of localhost in mysqlhost address
mine is working