connect remotly to mysql server - php

I want to connect to mysql server remotly .in the local host there is no problem. I check my.conf file but bind-address line and skip-networking no exist in the my.conf .this is my my.conf :
[mysqld]
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
when connect to mysql server from another server this error message displayed :
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'mysite.com' (13)
I add this line to my.conf :
bind-address= 0.0.0.0
and then restart mysql server but problem still exist .also I turn off firewall with iptables.
I think the problem is about port.default port is 3306. I try to change default port to 8806 but after change port mysql server does not start .
this problem take my time for several day. Can anyone help me?

Related

Xamp - mysql (3306 error)

Problem detected!
14:26:36 [mysql] Port 3306 in use by ""C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" xxx (PROJECT NAME)"!
14:26:36 [mysql] MySQL WILL NOT start without the configured ports free!
I can't shake this error. Xamp Apache runs great, but can't figure out how to get mysql running.
I tried:
Change php.ini:
mysql.default_port=3307
mysqli.default_port=3307
and my.ini:
[client]
# password = your_password
port = 3307
socket = "C:/xampp/mysql/mysql.sock"
[mysqld]
port= 3307
I don't want to uninstall Mysql workbench (as it has important dbs)
Additional information (I've Installed mysql workbench - not sure if this helps or not)
You could use netstat -lp | grep 3306 to find out what program is already listening on port 3306 (you should see PID/Program name in last column) and stop that (maybe mysql is already running?).
Alternatively you could start the newly installed server on a different port. (edit my.cnf and change the default port there)

Apache on Debian server to connect to extern mysql

I have servers :
a Sql server
a VPS
I installed apache on my debian server.
I want to access my SQL server through PDO.
But an error occurs :
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'my_sql_server_ip' (110)'
However, I can access my SQL server from local apache server (MAMP).
So I think the problem is client side.
Any suggestion ?
On MAMP , click File Menu > Edit Template > MySQL my.cnf
and change bind-address = 127.0.0.1 by bind-address = 0.0.0.0
(don't edit directly /Applications/MAMP/tmp/mysql/my.cnf because MAMP will overwrite the file on restart)

I am unable to use MySQL due to a "refused connection"

I am trying to run the no-install version of MySQL on Windows XP located in C:/mysql/ on my machine.
The error message I receive within a PHP file when I try to connect to MySQL reads.
Could not connect: No connection could be made because the target machine actively refused it
I have edited the config file my.ini and altered/added the following.
[client]
port = 3306
socket = C:/mysql/tmp/mysql.sock
[mysqld]
port = 3306
socket = C:/mysql/tmp/mysql.sock
basedir = C:/mysql/
datadir = C:/mysql/data/
bind-address = 127.0.0.1
skip-networking
enable-named-pipe
When I run mysqld.exe I can confirm it is running within command prompt tasklist.
However when I try cmd netstat -a I cannot see any port usage at 3306.
Inside MySQL error logs, it reads.
140411 13:30:34 [Note] c:\mysql\bin\mysqld.exe: ready for connections.
Version: '5.5.37-log' socket: '' port: 0 MySQL Community Server (GPL)
The port: 0 doesn't look correct to me, but I am not sure.
When I run mysql.exe direct in cmd I get the following returned
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
Some things I have tried already.
Placing a copy of my.ini in C:/WINDOWS and also a copy within C:/mysql
Changing bind-address = 127.0.0.1 to bind-address =
localhost
Inside PHP file MySQL connection variants, localhost, 127.0.0.1, 127.0.0.1:3306 inside basic mysql_connect()
Created tmp/mysql.sock file (in case dir + file not existing matters)
Commented out skip-networking in my.ini
After running mysqld.exe whilst running ran mysqladmin.exe in cmd which returns 'Can't connect to MySQL server at 'localhost'
Running telnet localhost 3306 returns
'Connecting To localhost...Could not open connection to the host, on port 3306: C
onnect failed'
Commented out bind-address in my.ini to allow default settings.
Ran mysqld.exe with user root (-u root) also inserted user = root in my.ini
Set Windows Firewall to off.
Thanks in advance.
Ok. You have binded your server to specific ip so please read this MySQL bind-addres. Please unbind your server and check if you have proper user. (last paragraph in documentation)

Remote connection to MySQL Linux

I opened up ports on my server
(results of netstat -L)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:mysql *:* LISTEN
...
but i can't connect to my server on that port via telnet, or remotely to my MySQL server. I am at my wit's end. How can I allow remote access on this port?
mysql -u -h 'my-server-ip' gives me an error that says '(HY000): Can't connect to MySQL server on 'my-server-ip' (10061)
Any help would be appreciated!
EDIT: SOLVED see my answer below
Are you sure you have the correct port open in iptables? MySQL usually listens on port 3306, but above you have port 3389 (which is usually used for RDP).
I rebooted my server and it worked :S
for any future readers, i opened up port 3306 on my firewall, inbound and outbound. then i commented out the binding_address line in my my.cnf file. i also granted access to remote users using phpmyadmin.

Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

When i connect my database by a php script it shows
Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
the username and password is right.
something of the my.cnf
[client]
#password = your_password
port = 3306
socket = /data/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
skip-external-locking
ps: i change it to socket = /var/lib/mysql/mysql.sock the php script still says "/var/lib/mysql/mysql.sock"?. then run
mysqladmin -u root -p status
it shows
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
service mysqld restart
mysqld: unrecognized service
Q: Does your my.conf still says "/var/lib/mysql/mysql.sock"?
Q: Does the directory "/var/lib/mysql" exist?
Q: Does your mysql user (or better, mysql group) have writer permission?
If so, please try re-starting mysql and see what happens.
ADDENDUM:
One other thing to try is to create a mysql.sock and explicitly give it permissions:
cd /var/lib
mkdir mysql
touch mysql/mysql.sock
chown -R mysql:mysql mysql

Categories