I have this server running LightHTTPD. I am trying access MySQL/PHPMyAdmin on this server. So far i have googled too much and tried so many things. I did this recently, edited this file /etc/mysql/my.conf, add bind-address = ip of my server;, then i did this:
mysql -u root -p
mysql> GRANT ALL ON databasename.* TO root#'0.0.0.0' IDENTIFIED BY 'pasword';
Now when i tried to connect to that server from IP i have granted, it gives me this error:
ini_set('display_errors',1);
error_reporting(E_ALL);
define("DB_NAME","pun_update");
define("DB_USER","root");
define("DB_PASS","");
define ("DB_SERVER","ip of my server");
function connect()
{
$db_handle = mysql_connect(DB_SERVER,DB_USER,DB_PASS)
or die("Unable to Connect to Database check your settings");
mysql_select_db(DB_NAME,$db_handle) or die ("Database doesnot exist");
}
connect();
I get this errror:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 110
Instead of using the IP try using the actual url of the remote server. Check this previous question.
update:
According to this page, error 110 is a connection timeout.
The MySQL site (MySQL server has gone away) cites instances which may cause this problem (you should check them out). Here is a notable one (for your case):
Another networking issue that can cause this error occurs if the MySQL port (default 3306) is blocked by your firewall, thus preventing any connections at all to the MySQL server.
There is another question (Lost connection...) which might be related to your problem if this is the cause.
Otherwise check that you are really connecting with the correct parameters. If possible try on the server itself.
Hope this helps!
Related
I recently had an issue with my production systems in which a MySQL server was blocking the application server, due to connection errors, and gave the following error:
Host 'xx.xx.xx.xx' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
I'd like to find a way to simulate this condition (or even trigger the actual condition on a non-production server), so I can respond to it properly. It's a pretty rare problem for my systems, but I'd still like to find a good way to respond to it.
You can avoid this problem by increase peer connections in mysql configurations
Logging to console/terminal with admin privileges
Flush all hosts using mysqladmin:
mysqladmin flush-hosts -u root -p
Open my.cnf (Linux) or my.ini (Windows) and change max_connect_error variable
max_connect_errors= 250000
Restart server with changes
To simulate error connection you can connect to MySQL server and then end connection before succesfull authentication. For example by netcat:
nc -i0.1 <hostname> 3306
I don't know if this is a user error on my end, or if the remote server is configured incorrectly.
I was given some connection info for a server as follows:
Server IP
server username
keyfile
mysql user
mysql password
and I can shell in and run the "mysql" command with the mysql user and password I was given, but I can't setup a connection in either MySQL Workbench or in HeidiSQL.
In MySQL Workbench, the 'Standard TCP/IP over SSH' seemed to best fit the info I was given, but when I try to connect I get "Authentication error. Please check that your username and password are correct and try again." or "Authentication error opening SSH tunnel: Authentication error. Please check that your username and password are correct and try again." in the logfile.
In HeidiSQL the "MySQL (SSH tunnel)" seemed to best fit the info I was given, but when I try to connect there, I get "Lost connection to MySQL server at 'reading initial communication packet', system error:0"
I looked up both these errors and couldn't find anything for the first one, and the second one seemed to be more about server configuration. I'm not too savvy with server config, so I'm a bit stuck evaluating whether or not I'm doing something wrong on my end, or if something needs to be changed on the server. I'd appreciate some advice. Thanks!
You must be more specific about the credentials you got. Is "server IP" the IP address of the MySQL server or an SSH server? Is the "server username" the SSH user or something else (e.g. a regular user of the target machine)? In my tutorial video on Youtube I explained what you have to use where to create a connection, including SSH connections: https://www.youtube.com/watch?v=DCgRF4KOYIY
You have to check a couple configuration steps before you can perform a remote mysql connection:
First of all you must check that mysql default port(3306) is listening on the correct interface.
You can check this out using netstat command in the remote server:
# netstat -tulnp
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1111/mysqld
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Then you must check that the remote host is allowed to perform querys into mysql engine (you must check user and host permissions over your database).
Connect into terminal and run the following command in mysql prompt:
mysql> select user,host from mysql.user;
Check the following link to deep insight mysql user and hosts system:
https://dev.mysql.com/doc/refman/5.0/en/adding-users.html
Check user,host permissions over your database:
mysql> show grants for root#localhost;
https://dev.mysql.com/doc/refman/5.1/en/grant.html
You must check that remote host (client) exist for example: user#192.168.1.2
Finally if you are using putty to encrypt over ssh you connection please check that you rsa key fingerprint is added you can perform this just logging ssh using you putty client.
I have followed the steps here:
ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server
Carried out this activity dozens of times and it worked -- now for some reason it is not
I have done:
Comment out bind-address in my.cnf and restart service
GRANT ALL PRIVILEGES ON . TO 'root'#'%';
FLUSH PRIVILEGES;
The only difference here is that MySQL is running in a VM under VirtualBox and I am connecting to the VM mysql instance via WIndows 7.
SSH and other services work fine...
The passwords are fine as they work when I connect via SSH...
My new modem/router possibly at fault, blocking outgoing or ingoing connections on port 3306???
I assume that traffic from a host to guest still goes through the router...but the thing is...my requests are certainly making to the MySQL server as the log file shows fail requests...
WTF amm I missing???
The error I receive: Error No. 1045
Access denied for user 'root'#'my-desktop' (Using Passowrd: YES)
You also have to edit my.cnf. Change:
bind-address = 127.0.0.1
to
#bind-address = 127.0.0.1
then restart mysql. Also, if you are going to allow outside access, create a user other than root. That's always a bad idea.
By default connection from outside are not allowed for security reasons.
Because exposing your database to the public internet is never a good idea, you will need to whitelist the IP address manually to allow connection.
MySQL error:
Failed to Connect to MySQL at 12.34.567.890:3306 with user jsdbadmin
Lost connection to MySQL server at 'reading initial communication packet', system error: 61
Using:
Plesk, SuSE vServer, fresh installation: completly new about an half year ago.
Software:
Trying to connect via MySQL Workbench, current version.
Hostname: 12.34.567.890 (modified for privacy), also tried with domain
Port: 3306
Username: My DB user name, as specified in Plesk when DB was created.
Password: *************
Default Schema: feeds
Tried TCP/IP, TC/IP over ssh.
Searched online:
These settings are not the problem:
#skip-networking
#bind-address = 127.0.0.1
Both already commented out.
Do you have a Firewall blocking the connection ?
You can test by telneting to the mysql port.
you also need to allow the ip/user combos that are allowed to connect
e.g.
to add a new user
GRANT ALL ON jsdbadmin.* TO remoteadmuser#'12.34.567.890' IDENTIFIED BY 'PASSWORD';
or
to grant access to a specific ip
update db set Host='12.34.567.890' where Db='yourdatabase';
update user set Host='12.34.567.890' where user='jsdbadmin';
Another possible (really annoying) error is that the server's public ssh keys have changed since your last login or that you've never logged in to that server using SSH and therefore you must manually approve them.
To solve this:
$ nano ~/.ssh/known_hosts
Remove old server keys from the file. Save & exit.
Connect to the server manually (ie. from terminal) and approve saving the new keys
After successful login from terminal, retry the mysql connection over ssh.
That worked for me...
I have mysql installed several months ago. However I do remember using mysql workbench successfully at one point of time. Today I try launching it and get following error
Lost connection to MySQL server at 'reading initial communication packet', system error: 61
open /etc/mysql/my.cnf in a text editor and try changing:
bind-address = 127.0.0.1
to
#bind-address = 127.0.0.1
and then restart MySQL.
Try using the connection method: Local Socket/Pipe.
If you are trying to use the MySQL Workbench and connect through an SSH tunnel, you will get this error when your SSH connection does not complete successfully (e.g. improper host, password, key file, etc)
A good way to trouble shoot this is to separately test the the ssh connection from the machine you are trying to connect from and establish that you can do so succesfully.
I came across the same problem.I fix this below:
3306 port may be occupied by other process, so mysql change the port to 3307(or nearly other port 3308...).So when you connect,change the port to 3307 and try