The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mysql port not specified in my.cnf, will it be 3306

Discussion in 'General Discussion' started by radical, Aug 31, 2005.

  1. radical

    radical Well-Known Member

    Joined:
    Nov 4, 2003
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    hi

    one my client is trying a MySQL Connector/J in an applet or application and he gets an
    exception similar to:

    SQLException: Cannot connect to MySQL server on host:3306.

    The /etc/my.cnf file on my server has just these enteries

    [mysqld]
    set-variable = max_connections=500
    safe-show-database
    query-cache-type = 1
    query-cache-size = 20M


    Is this ok for the applet to connect to the mysql server on port 3306 (even though it is not specified in my.cnf)

    How do i check if mysql is running on what port? should i add anything else in the my.cnf file?

    This is some documentation, i found on this error. can someone help me sort this out.

    QUOTE::
    Either you're running an Applet, your MySQL server has been installed with
    the "--skip-networking" option set, or your MySQL server has a firewall
    sitting in front of it.

    Applets can only make network connections back to the machine that runs the
    web server that served the .class files for the applet. This means that
    MySQL must run on the same machine (or you must have some sort of port
    re-direction) for this to work. This also means that you will not be able to
    test applets from your local file system, you must always deploy them to a
    web server.

    MySQL Connector/J can only communicate with MySQL using TCP/IP, as Java does
    not support Unix domain sockets. TCP/IP communication with MySQL might be
    affected if MySQL was started with the "--skip-networking" flag, or if it is
    firewalled.

    If MySQL has been started with the "--skip-networking" option set (the
    Debian Linux package of MySQL server does this for example), you need to
    comment it out in the file /etc/mysql/my.cnf or /etc/my.cnf. Of course your
    my.cnf file might also exist in the "data" directory of your MySQL server,
    or anywhere else (depending on how MySQL was compiled for your system).
    Binaries created by MySQL AB always look in /etc/my.cnf and
    [datadir]/my.cnf. If your MySQL server has been firewalled, you will need to
    have the firewall configured to allow TCP/IP connections from the host where
    your Java code is running to the MySQL server on the port that MySQL is
    listening to (by default, 3306).

    END QUOTE::
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Yes, it runs on port 3306 unless otherwise specified. You can see it yourself by running:

    netstat -lpn | grep mysql

    A couple of things to check:

    1. If you have an iptables firewall (e.g. APF) have you opened port 3306 for inbound traffic

    2. You may have to add a wildcard to cPanel > MySQL > Access Hosts for the user.
     
  3. radical

    radical Well-Known Member

    Joined:
    Nov 4, 2003
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    Apf enabling 3306

    hi chirpy

    you had installed ms and apf for me as part of the ms+cpanel package. How do i enable 3306 in apf and regarding adding the wildcard, do i do this in WHM?

    thanks
    Sunil
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Hi Sunil,

    Do the APF mod first and try it again:

    edit /etc/apf/conf.apf and add 3306 to the comma separated list IG_TCP_CPORTS and the reload APF:

    apf -r

    See if it now works. If not, then you can add the wildcard in through the users cPanel account as I mentioned above.
     
  5. radical

    radical Well-Known Member

    Joined:
    Nov 4, 2003
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    hello chirpy

    added the port to the APF allowed list, but now i am getting another error.

    java.sql.SQLException: Server configuration denies access to data source

    Can i add just a "%" in the Host field, in order to specify a wildcard? sorry a dumb question i guess

    Sunil
     
  6. nickb

    nickb Well-Known Member

    Joined:
    Feb 25, 2005
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    Yes you can safely add "%" wildcard without quotes in cpanel>>mysql>>access hosts
     
  7. radical

    radical Well-Known Member

    Joined:
    Nov 4, 2003
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    hi

    added the wildcard, now it throws up the error

    access denied to database for user_username@% for database user_dbname

    any ideas?
     
  8. yoshika

    yoshika Member

    Joined:
    Feb 24, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    I am edit /etc/apf/conf.apf and add 3306 to the comma separated list IG_TCP_CPORTS and the reload APF:

    apf -r

    and i also to add the wildcard in through the users cPanel account .
    But still not work ,so what can i do ,thanks your replay.



     
Loading...

Share This Page