Problem: mssql_connect () connection in CentOS, "Unabletoconnecttoserver" problem.

Source: Internet
Author: User
Tags mssql server mssqlserver
For more information, see Unabletoconnecttoserver. When mssql_connect () is used in CentOS, the error message "Unable to connect server" is always displayed.

Background: The web server of centOS needs to connect to the database server of MSSQL. The mssql database uses MSSSQL2000. (MSSQL2008 has also tried, and the problem is the same ).

In centOS, Freetds and php-mssql modules are installed using yum install. use phpinfo () to check whether php-mssql has been installed successfully. Use tsql in centOS to test the connection to the mssql account and password. However, when the mssql_connect () function is used to connect to the PHP file, the error message "Unable to connect server" always appears (query by error_log ).

Program code:
$ Link = mssql_connect ('2017. 168.100.10: 1433 ', 'sa', '*****'); // an error occurs. Add the port number: 1433 without adding it. if (! $ Link)
{
Die ('unable to connect! Error: '. mssql_get_last_message ());
}
?>


Please solve it!


Reply to discussion (solution)

Is there a clear error message that cannot be connected?
Output mssql_get_last_message () to see what it is.
It seems that the installation is normal. what is the permission? In SQL server, if sa is not recorded successfully, the final setting will be solved.
Try again to get more detailed error information

You can also change the ip address to localhost or 127.0.0.1 and try again.

You do not have permission. of course you cannot connect.

Is it the original code? Why did I get an error in mysql_connect ????

The project needs to connect to the previous database server. The previous database was MSSQLServer2000 and is now migrated to the web environment. The mssql module of php is required.
The web server is structured in linux, and the database is another windows MSSqlServer server. Therefore, it is definitely not the same as using localhost or 127.0.0.1. Because the database in the first step has not been connected, mssql_get_last_message () has feedback.
This should not be a permission issue. you have already used the tsql method for query, and all queries are normal.
In addition, on another computer, manually decompress and install freetds and php, recompile and install, and connect to the mssql database.
My judgment is that when I installed freetds and php-mssql in yum mode, I don't know which step is missing. Therefore, I would like to ask if there are any experts in this regard.

The database is another windows MSSqlServer server !!!
Are you using cross-origin access?
The default MSSQL installation does not allow remote connection. you need to open the remote connection in the server configuration manager to connect to the server.
In addition, remote connections are also affected by the firewall. normal connections can be disabled at any end (client and server.
We recommend that you first configure the network environment, then check the MSSQL configuration, and finally check your PHP program.

You have already said: TSQL has tested the MSSQL connection and the query is normal! The parameters are correct, but the mssql_connect () function cannot be used. Of course it's not about MSSQL server configuration, nor about firewall and network environments.

Query the/var/log/httpd/error_log log under centOS. warning: mssql_connect (): Unable to connect to server: 192.168.100.10: 1433 in ....."

In my opinion, I do not know what went wrong when I installed freetds and php-mssql in yum.

If you have experience using yum configuration in centOS, please try again!

Solve the problem by yourself.
Two methods:
1. run the command setenforce 0.
2. open/etc/selinux/config, set SELINUX to disabled, and restart.

I also met a model I? ??, I found a lot of places to see ?,?? Gangang solution ?? What ??? Why?

I also want to know how to solve this problem. this is the same question I raised, but it is more detailed. Http://ask.csdn.net/questions/69462

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.