Home Database Mysql Tutorial SQL Relay开源的数据库池连接代理服务器

SQL Relay开源的数据库池连接代理服务器

Jun 07, 2016 pm 03:15 PM
relay sql acting Open source database server connect

一、SQL Relay是什么? SQL Relay是一个开源的数据库池连接代理服务器 二、SQL Relay支持哪些数据库? * Oracle * MySQL * mSQL * PostgreSQL * Sybase * MS SQL Server * IBM DB2 * Interbase * Sybase * SQLite * Lago * ODBC * MS Access 三、安装和配置

一、SQL Relay是什么?

SQL Relay是一个开源的数据库池连接代理服务器


二、SQL Relay支持哪些数据库?

<span> * Oracle<br>* MySQL<br>* mSQL<br>* PostgreSQL<br>* Sybase<br>* MS SQL Server<br>* IBM DB2<br>* Interbase<br>* Sybase<br>* SQLite<br>* Lago<br>* ODBC<br>* MS Access</span>


三、安装和配置;

不说废话了,开始安装SQL Relay,到 http://sqlrelay.sourceforge.net/ 去下载相应的软件
安装SQL Relay需要先安装Rudiments, 在 http://sqlrelay.sourceforge.net/download.html 可以找到


1、安装Rudiments:

<span># tar vxzf rudiments-0.28.2.tar.gz<br># cd rudiments-0.28.2<br># ./configure --prefix=/usr/local/rudiments<br># make<br># make install</span>

至此,rudiments安装结束


2、安装SQL Relay:

<span># tar vxzf sqlrelay-0.36.4.tar.gz<br># cd sqlrelay-0.36.4<br># ./configure --prefix=/usr/local/sqlrelay --with-rudiments-prefix=/usr/local/rudiments --with-mysql-prefix=MySQL安装路径 --with-freetds-prefix=FreeTDS安装路径 --with-oracle-home=Oracle安装路径 --with-php-prefix=PHP安装路径<br># make<br># make install</span>

安装结束,以上编译参数根据个人需要来设定,因为我同时需要Oracle SQLserver MySQL,所以才加了这么多参数的

3、设置PHP:

修改php.ini

<span>extension_dir = "./"</span>

把以上内容修改为:

<span>extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922"</span>

根据PHP安装的路径来修改,并不是每个版本的PHP都是这个路径
在php.ini中添加如下内容

<span>extension=sql_relay.so</span>

接下来,介绍SQL Relay如何连接SQL Server
修改FreeTDS的配置文件freetds.conf
加入如下内容:

<span>[msde]<br>host = 172.16.20.203<br>port =1433<br>tds version = 8.0<br>client charset = GB2312</span>

请根据个人需求来修改


4、修改SQL Relay的配置文件

<span># cd /usr/local/sqlrelay/etc<br># cp sqlrelay.conf.example sqlrelay.conf</span>

把sqlrelay.conf的内容改为:

<span><?xml version="1.0"?><br><br><br><br><br><br><br><br><br><br><br></span>


四、启动SQL Relay,并测试;


1、启动 SQL Relay

<span># export PATH=$PATH:/usr/local/sqlrelay/bin<br># sqlr-start -id msdetest</span>


2、使用SQL工具:

<span># sqlrsh -id msdetest</span>

可以直接输入SQL语句

停止SQL Relay:

<span># sqlr-stop msdetest</span>


3、测试PHP:

写一个PHP文件,内容如下:

<span><br>$con=sqlrcon_alloc("msdetest",9000,"/tmp/msdetest.socket","sa","sa",0,1);<br>$cur=sqlrcur_alloc($con);<br>sqlrcur_sendQuery($cur,"select * from t_gifts");<br>for ($row=0; $row<sqlrcur_rowcount></sqlrcur_rowcount>for ($col=0; $col<sqlrcur_colcount></sqlrcur_colcount>echo sqlrcur_getField($cur,$row,$col);<br>echo ",";<br>}<br>echo "<br>\n";<br>}<br>sqlrcur_free($cur);<br>sqlrcon_free($con);<br>?></span>

执行这个PHP文件,看看能不能出现数据
全文结束~~

 

参考:http://hi.baidu.com/mrvsumbeujeinxe/item/8ba0c60888cf47c490571896

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Jul 23, 2024 pm 09:34 PM

According to news from this website on July 23, ASUS has launched a variety of server and workstation-level products powered by AMD EPYC 4004 series processors. Note from this site: AMD launched the AM5 platform and Zen4 architecture EPYC 4004 series processors in May, offering up to 16-core 3DV-Cache specifications. ASUSProER100AB6 server ASUSProER100AB6 is a 1U rack server product equipped with EPYC Xiaolong 4004 series processor, suitable for the needs of IDC and small and medium-sized enterprises. ASUSExpertCenterProET500AB6 workstation ASUSExpertCenterProET500AB6 is a

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

PHP Database Connection Pitfalls: Avoid Common Mistakes and Misunderstandings PHP Database Connection Pitfalls: Avoid Common Mistakes and Misunderstandings Jun 05, 2024 pm 10:21 PM

To avoid PHP database connection errors, follow best practices: check for connection errors and match variable names with credentials. Use secure storage or environment variables to avoid hardcoding credentials. Close the connection after use to prevent SQL injection and use prepared statements or bound parameters.

See all articles