Apache on Debian server to connect to extern mysql - php

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)

Related

Xampp 1.8.3 localhost phpmyadmin error code 2000#

I need your help to resolve the below issue.
I have installed XAMPP server on a virtual machine having Windows 10. I changed the ports from 80 to 8080 and MySQL from 3306 to 3307. Still, I am getting an error when I try to access phpMyAdmin using localhost
Did you also change the phpmyadmin configuration to use the new port?
If not do it with the following steps:
Open the xampp controlpanel
click config behind apache -> then click phpMyAdmin
search for the line $cfg['Servers'][$i]['host'] = '127.0.0.1'; and add $cfg['Servers'][$i]['port'] = 'your new port number'; under it
save the file

configure php from Redhat to connect to MS SQL Server

I'm trying to deploy Moodle LMS on Redhat server with php56 and I want to connect it to another remote MS SQL server through freetds and php-mssql,How to configure them together to be able to connect the Moodle LMS to the database?
Assuming you installed all needed packages (php-mssql and freetds).
You have to add an entry in /etc/freetds.conf like this:
[mydb]
host = 10.0.0.199
port = 1433
tds version = 8.0
client charset = UTF-8
text size = 20971520
Restart httpd (service httpd restart)
Then in moodle set db name to mydb and everything will work.
It could be that you will have to set/disable selinux for moodle. do this temporarily in this way :
setenforce 0
Then edit /etc/selinuc/config for next boot.
Good Luck!

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)

MySQL: Error #2002

I'm trying to install an opensource software on my local and I'm running zendserver on linux ubuntu.
I created the database and provided a correct user and password.
But as soon as I click on submit button I get a MySQL 2002 error saying:
(2002) No such file or directory
I tried to restart apache2 but still I get the same error after I have restarted apache2.
How can I resolve this Mysql error?
You don't have permissions to access the directory /var/lib/mysql/whatever.sock because mysql is the owner of the folder
or
/path/whatever.sock doesn't exist.
You can try this though [Linux specific, but what other operating systems are there?]
Go to /etc/my.cnf and change/add the lines:
[mysqld]
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
[client]
socket=/tmp/mysql.sock
This way the client and server use the same socket and it's in a public directory.

Connecting to MSSQL server using LAMP

I have a LAMP server (Ubuntu 12.04, Apache/2.2.22, MySQL 5.5.24, PHP 5.3.10).
However I also want to connect to other MsSQL server on other machine using Apache & PHP
with a credentials of:
Server name: HENYO-GP-TEST\HENYO_GPTEST
IP: 192.168.1.36
Username: someuser
Password: somepass
Database: somedb
I already installed FreeDTS using 'apt-get install freetds-common freetds-bin unixodbc php5-sybase', then configured it by 'vim /etc/freetds/freetds.conf' then edit the bottom part like this
# A typical Microsoft server
[192.168.1.36]
host = 192.168.1.36
port = 1433
tds version = 8.0
but upon testing using 'tsql -S 192.168.1.36 -U someuser -P somepass -D somedb', the following error occured.
locale is "en_PH.UTF-8"
locale charset is "UTF-8"
using default charset is "UTF-8"
Default database being set to FAC
Error 20009 (severity 9):
Unable to connect: Adaptive Server is unavailable or does not exist
OS error 111, "Connection refused"
There was a problem connecting to the server
But I know the server is on because I can ping it.
Is the connection to MSSQL server (reside on other machine) possible using LAMP?
If it is possible? What are my mistakes on the installation and configuration? Thanks in advance.
Pinging a server doesn't necessarily imply that a particular port is open; it may respond to ICMP requests, but there's no guarantee that a given port is open. Have you confirmed that port 1433 is open on the remote server and that there is nothing blocking traffic to that port?
Your SQL Server is running on an instance named HENYO_GPTEST (HENYO-GP-TEST is the server name, and HENYO_GPTEST is the instance name), but you are not specifying this instance name anywhere.
I'm not familiar with FreeTDS, so I don't know how to specify that, but you need to specify this instance name in order to connect to the server.

Categories