


求助:CentOS下的mssql_connect()连接问题,出现"Unable to connect to server"问题。
在CentOS系统下使用mssql_connect()时,一直出现“Unable to connect server”错误提示。
背景: centOS系统的web服务器需要连接 MSSQL 的数据库服务器。mssql数据库使用的是MSSSQL2000,(MSSQL2008也试过,问题同样)。
centOS系统使用 yum install方式安装了 Freetds和 php-mssql模块,使用 phpinfo()查看php-mssql已经安装成功。在centOS下使用 tsql测试连接mssql账号密码,都正确。但是php文件中使用mssql_connect()函数连接时,总出现“ Unable to connect server”的故障提示(通过 error_log查询)。
程序代码:
$link = mssql_connect('192.168.100.10:1433', 'sa', '****'); // 此处总出现错误,加不加端口号:1433,故障依旧 if (!$link)
{
die('Unable to connect! error: ' . mssql_get_last_message());
}
?>
求高人解决!
回复讨论(解决方案)
就一个不能连接,无更明了的错误信息?
输出mssql_get_last_message()看看是啥
看样子是安装正常了,权限?sql server我遇过sa没录成功的情况,最终设置才解决
你再测试一下,争取得出更详尽的错误信息
还有你把ip换为localhost或是127.0.0.1再试试
你没权限,当然连不上去
是原有的代码吗? 我怎么看着mysql_connect()都写错了????
项目需要连接早先的数据库服务器, 以前的数据库是MSSQLServer2000,现在要迁移到web环境。所以需要用到php的mssql模块。
web服务器架的是linux结构,数据库端是另外一台windows的MSSqlServer服务器,所以和用localhost或127.0.0.1肯定是不对路。 因为第一步数据库还没有连接上,所以mssql_get_last_message()还有信息反馈回来。
应该也不是权限问题,已经用tsql方式查询过了,一切查询都正常。
另,在另外一台电脑上,使用手工方式解压安装freetds、php,重新编译安装,可以正常连接mssql数据库。
我的判断是用 yum 方式安装freetds和php-mssql时,不清楚是否还欠缺哪一步。所以请教有没有这方面的高人。
数据库端是另外一台windows的MSSqlServer服务器!!!
你是跨域访问吗,晕
默认安装的MSSQL,是不允许远程链接的,需要到 服务器配置管理器中,开放远程链接后,才能正常链接。
另外,远程链接,还受防火墙的影响,任何一端(即客户端和服务器端)的防火墙,都可以禁止其正常链接。
建议先配置好网络环境,再检查MSSQL的配置,最后才是检查您的PHP程序。
都已经说过了: TSQL已经测试过到MSSQL的连接,查询正常!参数都没有问题,只是在使用无法使用mssql_connect()函数。 当然不是MSSQL的服务器配置问题,也不是防火墙和网络环境问题。
查询centOS下的/var/log/httpd/error_log 日志,出现“...Warning: mssql_connect(): Unable to connect to server: 192.168.100.10:1433 in ....."
我的判断是yum 安装freetds和php-mssql时,不知哪里出了问题。
求有centOS下使用yum配置经验的高人来解!
自己解决。
两种方法:
1、运行命令 setenforce 0
2、打开 /etc/selinux/config ,将SELINUX设置为disabled,然后重新启动。
我也遇到一模一?的??,找了很多地方才看到?,??gangang解??何???理即可?
同样想知道怎么解决,这是我提出一样的问题,但写的更详细。http://ask.csdn.net/questions/69462

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Methods for using Chinese input in CentOS include: using the fcitx input method: install and enable fcitx, set shortcut keys, press the shortcut keys to switch input methods, and input pinyin to generate candidate words. Use iBus input method: Install and enable iBus, set shortcut keys, press the shortcut keys to switch input methods, and input pinyin to generate candidate words.

To read U disk files in CentOS 7, you need to first connect the U disk and confirm its device name. Then, use the following steps to read the file: Mount the USB flash drive: mount /dev/sdb1 /media/sdb1 (replace "/dev/sdb1" with the actual device name) Browse the USB flash drive file: ls /media/sdb1; cd /media /sdb1/directory; cat file name

There are two ways to enter the root authority of CentOS 7: use the sudo command: enter sudo su - in the terminal and enter the current user password. Log in directly as the root user: Select "Other" on the login screen, enter "root" and the root password. Note: Operate carefully with root privileges, perform tasks with sudo privileges, and change the root password regularly.

Solutions for forgotten CentOS passwords include: Single-user mode: Enter single-user mode and reset the password using passwd root. Rescue Mode: Boot from CentOS Live CD/USB, mount root partition and reset password. Remote access: Use SSH to connect remotely and reset the password with sudo passwd root.

One can use the scp command to securely copy files between network hosts. It uses ssh for data transfer and authentication. Typical syntax is: scpfile1user@host:/path/to/dest/scp -r/path/to/source/user@host:/path/to/dest/scp exclude files I don't think you can when using scp command Filter or exclude files. However, there is a good workaround to exclude the file and copy it securely using ssh. This page explains how to filter or exclude files when copying directories recursively using scp. How to use rsync command to exclude files The syntax is: rsyncav-essh-

After forgetting your CentOS username and password, there are two ways to restore access: Reset the root password: Restart the server, edit the kernel command line in the GRUB menu, add "rw init=/sysroot/bin/sh" and press Ctrl+x ;Mount the root file system and reset the password in single-user mode. Use rescue mode: Start the server from the CentOS installation ISO image, select rescue mode; mount the root file system, copy the chroot environment from the ISO image, reset the password, exit the chroot environment and restart the server.

CentOS 7 disables root permissions by default. You can enable it by following the following steps: Temporarily enable it: Enter "su root" on the terminal and enter the root password. Permanently enabled: Edit "/etc/ssh/sshd_config", change "PermitRootLogin no" to "yes", and restart the SSH service.

Three solutions for forgotten passwords in CentOS 7: Single-user mode: Restart the system, edit the kernel options, change ro to rw init=/sysroot/bin/sh, and use the passwd command to reset the root password. Rescue mode: Boot from the installation media, select rescue mode, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password. Grub2 command line: Restart the system, press c to enter the command line, load the kernel, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password.
