Mysql access over LAN - mysql

I have created a java application which connects to a mysql database using the JDBC driver. I have the mysql server running on the same machine as my java application.
When I connect to the database on localhost the application is working fine. My system in connected to other systems via LAN. Now i want to run my application on these systems connecting to the database on the mysql server i have on my system.
What changes do i need to make in my mysql workbench or the java application to deploy this. I have mysql 6.1 workbench installed.
I am getting the following error:
run: Communications link failure
Last packet sent to the server was 0 ms ago. Exception in thread
"AWT-EventQueue-0" java.lang.NullPointerException
at help.helpdesk.Ready(helpdesk.java:97)
at help.helpdesk.<init>(helpdesk.java:89)
at help.helpdesk$6.run(helpdesk.java:428)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) BUILD
SUCCESSFUL (total time: 22 seconds)
when I try to connect to the database on my local server by using the ip address of my system.

If you set bind-address = 0.0.0.0 in /etc/my.cnf, MySQL will be available across all interfaces both locally and over the network.

You need to do following changes
1.Edit the my.cnf
mysql/my.cnf
change the local ip
bind-address = 192.168.1.2("your system ip")
2.restart the mysql server
and if you want connect to your database remotely than this link will helpful for you

Related

JetBrains can not connect with a Hosted MySQL Database

I have a MySQL-Database from a hostingservice (strato.de). I try to connect the JetBrains DataGrip with this MySQL Database. I tried to connect but I get everytime a timeout. So I tried it with SSH but there I got this error:
[08001] Could not create connection to database server. Attempted
reconnect 3 times. Giving up. java.io.EOFException: Can not read
response from server. Expected to read 4 bytes, read 0 bytes before
connection was unexpectedly lost.
I do not understand the problem... is the Firewall blocking the connection?
How can I connect JetBrains with my Hosted MySQL-Database?
Make sure your hosting provider exposed MySQL database port for external connections.
Have you tried to connect via MySQL Workbench?
Just in case read JetBrains help topic

MySQL connection works for Workbench but not Tomcat Application using same credentials

I am working on a remote Redhat system over SSH. Tomcat 7 and MySQL 5.5 server are both installed and appear to be running correctly.
I can connect to MySQL from a local install of Workbench over SSH tunneling using localhost and a defined MySQL user. I can run queries and navigate tables without incident.
When I try to connect to the same MySQL Server with a Tomcat application running in the same environment using the MySQL defined user (same credentials) that Workbench is connecting with successfully, it fails.
At this point I don't know the exact error message that gets generated (I am not an admin) so any guidance here is appreciated.
My question is why can I connect with Workbench (which is effectively connecting locally), but not with my Tomcat application, which actually is local to the server?
Might it be a permissions issue with the context Tomcat is running under?
References:
Connection string example (credentials have been altered):
jdbc:mysql://localhost/mysql_database_name?user=ApplicationUsername&password=ApplicationPassword"
Furthermore, I have verified that
mysql-connector-java-5.1.27-bin.jar
is in the WEB-INF folder, and:
Class.forName("com.mysql.jdbc.Driver");
resolves.
This web application works in both dev and test on another server connecting using respective credentials.
Be sure the port number of mysql server exists in connection string. Normally if port is not specified, default value would be used as 3306. Maybe your mysql runs on different port?
jdbc:mysql://[host][,failoverhost...][:port]/[database] »
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
If the host name is not specified, it defaults to 127.0.0.1. If the port is not specified, it defaults to 3306, the default port number for MySQL servers.

Unable to connect to MYSQL on a remote computer

I am working on windows and having a remote desktop connection of another machine. I am trying to connect to the mysql running on the remote machine through my MySql workbench, installed on my machine.
When I specify the details to connect to mysql i.e.
IP- a.b.c.d
port-3306
username=root
password=
But everytime it shows me an error saying-
Your connection attempt to connect to user='root'failed from your host to server at a.b.c.d:3306
Is it possible that I can connect to mysql on a different machine?
Certainly that is possible, mysql is a network transparent service. However obviously the normal access authorization rules apply.
do you have network access to the mysql port, this might be blocked by a firewall. You can check that by using telnet ip-address-of-server 3306. Does the server answer or do you get a timeout or are blocked? (the answer would look cryptic, soomething like 5.5.33-MariaDB[*[n7p~g!�iXccI$r9``Y{$mysql_native_password or similar )
the mysql server can be configured to not listen to remote connections. This can add security to the setup, but would obviously block any remote connection attempts. You will have to check the configuration files of mysql for that.
mysql itself implements an authorization level. So check if that 'root' user actually is allowed to connect from the outside. Those authorizations are stored in the internal "mysql" database.
Also it is not clear from the question what your network topology is: is the mysql server running on that system you have a "remote connection" to? Is the mysql-workbench running on that remote system or on your local system? This might affect the ip address you have to use inside the workbench.

Unable to connect to XAMPP MySQL from Netbeans

I am a windows 7 user and I'm having an issue with MySQL and XAMPP.
I use the MySQL that comes with XAMPP. I have changed the root password of MySQL using XAMPP's security page. Then I tried to connect to the MySQL server via Netbeans.
To try to connect I clicked on MySQL server option in the database drop down of the services pane, I gave it some settings:
server host name:localhost
username:root
port:3306
password:(my sql password)
path to admin module:(http:'//')localhost/phpmyadmin
sql start path:D:\D-drive\xampp-portable\mysql\bin\mysqld.exe(also tried mysql_start.bat)
sql stop path:</b>D:\D-drive\xampp-portable\mysql\bin\mysqladmin.exe(also tried sql_stop.bat)
Then I right click on MySQL server at localhost [root] and select Connect, this is when I get an error:
Unable to connect to the MySQL server:
org.netbeans.api.db.explorer.DatabaseException: org.netbeans.api.db.explorer.DatabaseException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server..
The server may not be running or your MySQL connection properties may not be set correctly. Do you want to edit your MySQL connection properties?
Changing localhost to 127.0.0.1 doesn't work either. I have the jdbc driver as well.
The fix that worked for me is as follows:
Please see that netbeans is an allowed program in your firewall as well as antivirus software
to check:
if netbeans startup page says "cannot connect to internet" then you must change your firewall and/or antivirus settings to allow it

random connection error cant connect to mysql database server 10060

Our Application is using mysql database from remote linux server at port 3306
Application is connecting to database server using TCP/IP protocol from windows xp service pack 3 machine.Application works well almost all time but some times it is giving following error randomly "[MySQL][ODBC 5.1 Driver]Can't connect to MySQL Server on 'IP Adderss' (10060)". Only one desktop user is facing this issue from around 240 users.
Application is developed in VB6.
Database server: mysql 5.1.51
can any one suggest possible cause of this error ?
As the error occurs randomly in just one client machine , we have change network card on particular machine and then user has not face same issue from last week.It was due to interrupted network connectivity of client machine to database server