Amazon EC2 Tomcat7 instance unable to access MySQL db on same system - mysql

I think I've seen a variety of similar posts on this topic, but am still unable to resolve my issue, so I figured I'd post with my specifics.
I have an Amazon AWS Linux EC2 instance running Tomcat7 web server. On the same machine I am also running a MySQL5 server, but I am unable to get the Tomcat app to talk to the MySQL database.
My Java app on tomcat tries to connect to MySQL by reading from a properties file:
jdbc.mysql.host.path=jdbc:mysql://localhost/
jdbc.mysql.schema=prod
jdbc.mysql.username=root
jdbc.mysql.password=<password>
I am accessing the app from another system via web browser, but when the app tries to connect to the database I get the following error in catalina.out:
java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
I'm pretty sure the issue has to do with permissions and communication between Tomcat and MySQL, because I've written a simple java program utilizing the same code to read the same properties file, and the connection is made successfully.
Here are some things I have attempted to remedy the issue:
change the owner of the properties file (currently owned by 'Tomcat')
ensured that user 'root' has been granted all privileges in MySQL
ensured that port 3306 (MySQL default port) is accessible by my test server
updated iptables made various modifications to /etc/my.cnf file
(tried to bind ip, but that didn't work)
I have a hunch that the issue may be related to the fact that I am trying to access the MySQL database using user 'root'. Even though I'm accessing it via localhost, the system may not support this because MySQL treats this as access from a separate host and (maybe?) root access from other hosts isn't allowed?
Any suggestions on things to try would be greatly appreciated...

I believe the issue was a combination of things.
Here are some items to consider that ultimately fixed it for me:
- making sure you were accessing the correct app via browser (I was using ROOT app, but trying to connect to another one)
- making sure a user exists in MySQL using 'Create User ....'
- making sure all privileges are granted on the database in question, for some reason granting all privileges on . wasn't working for me

Related

Connecting to a remote mySql server from my local machine

My main problem right now is that I can't connect to the remote mysql server while developing on my machine. I'm trying to update a website that was previously developed by someone I do not know. I've been editing the site on my local machine but I need to access data from the mysql database that it has been using. I have the username and password that the site uses to connect to the mysql server. I can connect to it through phpmyadmin but I would like to work locally without publishing my edits to the server.
I found this here in SO and I tried running the scripts in phpmyadmin using my pc's IPaddress but I keep getting
Access denied for user 'username'#'localhost' (using password: YES)
even though I'm 100% sure I'm using the password that I used to login to phpmyadmin. I tried creating a new user but the login I'm using doesn't seem to have a Create User privilege either.
I understand that the previous developer might have a different "admin" account that has all the privileges but I have no way of knowing either.
I am a C# developer but I'm really new to MySql. Any help is greatly appreciated.
This may be a firewall issue. phpmyadmin listens on port 80 by default, but mySQL listens on port 3306. Please check the firewalls on your local PC (to make sure you can get out on 3306) and the server (to make sure you can get in on 3306).

How to access my newly setup MySQL database (getting "Domain is currently unable to handle this request.")

I just set up a new MySQL database with the MySQL workbench & created a user for it with all necessary privileges. I am using this database for use with my php code. But I can't seem to connect to it on my live server (pages are hosted on windows server 2012). Everything works fine in my local environment with xampp and the new MySQL database is exactly the same as the xampp one. I think I am maybe using the wrong host name or something. As host name I copied the name that is displayed after "Host:" when you click on Server Status in MySQL workbench. The database name, user & password should all be correct. But when my code tries to access the db I get a "The domain page isn’t working. Domain is currently unable to handle this request."
You either have no network connection to the server at all or it is blocked due to firewall or routing misconfiguration.
If you do have network access in general, you might forgot to
FLUSH PRIVILEGES;
or you have not enabled networking over TCP, the default is to listen only to localhost (on unix systems via unix sockets, on microsoft I guess it's simply TCP).
Read about the following configuration parameter which will solve your networking issue:
bind-address
If you have a very old MySQL server version, the parameter is enable-networking but it shouldn't be the case anymore.

Unable to connect to local MySQL DB using Laravel

I have a local database that I can connect to no problem using straight php
However, when I use the same settings in Laravel, I get an access denied error message
I checked stackoverflow for this type of error and most cases is solved by using 127.0.0.1. I made sure to try both 127.0.0.1 and localhost whenever asked for host/server.
Also, I made sure root had sufficient privileges
Here are my configuration settings, I tried to use different accounts, other than root, and also changing 127.0.0.1 to localhost (and the opposite)
database.php file
.env file
Hoping to learn this framework, I've heard great things. Appreciate any help
Sounds like you are trying the connection both with the script and laravel from a different Server like homestead.
Normally there are restrictions that you can't connect from remote (i.e. from a VM like homestead) to a certain server (i.e. localhost) with the root user.
Possible Solutions:
1. Create another user with the relevant permissions on mysql and connect with that one.
2. Look in the web for how to allow remote connections
3. Go the laravel way and use the homestead DB inside of the VM
First, are you sure you typed the password correctly?
Second, are you using the homestead virtual box? If yes, the default user is "homestead" and the pass is "secret" without quotes of course. Try putting that in the .env file

MySQL Server Connection in PhpStorm 2016

This seems like the most annoying thing in the world, but for some odd reason, I'm not able to connect my MySQL DB in PhpStorm (as a data source). It constantly tells me that the user/password combo is incorrect. Here's the complete error message:
The specified user/password combination is rejected: [28000][1045] Access denied for user 'my_username'#'localhost' (using password: YES).
I know for a fact that my credentials are correct. I've checked and double checked. Even created a few new users.
I know that the credentials are correct because the application I'm writing is successfully connected to this DB.
And, as an FYI, the DB I'm trying to connect to is hosted on GoDaddy (shared CPanel Linux hosting).
PS: I've also tried using my website's IP as the host to no avail.

Connecting Funambol to MySQL on remote host

I am setting up Funambol 8.7 on a Linux host (using Amazon AWS). I need to connect to a MySQL datbase that is hosted on a different server.
Per the administration guide I went ahead and downloaded the mysql connector and placed the jar in /opt/Funambol/tools/jre-1.6.0/lib/ext. I changed the install.properties file as follows:
dbms=mysql
jdbc.classpath=/opt/Funambol/tools/jre-1.6.0/jre/lib/ext/mysql-connector-java-5.1.14-bin.jar
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://myserver.net/rugcutte_funambol?characterEncoding=UTF-8
jdbc.user=rugcutte_funambo
jdbc.password=funambol
THen I try to run the install, but get the following error:
/opt/Funambol/ds-server/install/install.xml:452: java.sql.SQLException: Access denied for user 'rugcutte_funambo'#'ec2-50-16-233-200.compute-1.amazonaws.com' (using password: YES)
It appears my AWS instance can connect successfully to my MySQL database however it is trying to login with a fully qualified user name that is incorrect: rugcutte_funambo'#'ec2-50-16-233-200.compute-1.amazonaws.com
I tried also to change the line to : jdbc.user=rugcutte_funambo#myserver.net . But I got a similar error with that as well.
I am relatively inexperienced to JDBC. What is the proper way to set up this section of the install.properties file?
Did you enable access to that database with that user from that server?
What happens if you try and just make the same mysql connection from the command line from your Funambol server?
Thanks Adam.
You led me to the correct answer. The remote host has an area in cPanel to configure Remote Database Access Hosts. So I did, need to add my source host that is running Funambol, to my list of access hosts.
After this I ran the install and it did, appear to create the tables properly in the database running on my remote host.