如何在 Ubuntu 16.04 上安装 Firebird?

Lum*_*aja 3 software-installation 16.04

我找不到安装 Firebird 版本的好方法。2.5 或 ver. 3.0.

这可能吗?如果是这样怎么办?

小智 5

根据官方 Ubuntu 文档

Firebird stable 2.5.x位于存储库 (ppa) 中,用于 LTS 和当前支持的Ubuntu 版本

必须以这种方式添加 ppa 存储库

sudo add-apt-repository ppa:mapopa
Run Code Online (Sandbox Code Playgroud)

然后你需要更新缓存库

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

以下是检查 firebird2.5 相关软件包的方法

apt-cache search firebird2.5-*
Run Code Online (Sandbox Code Playgroud)

安装超级服务器包(你会被问到 SYSDBA 密码和要启用的服务:超级服务器、经典或超级经典)

sudo apt-get install firebird2.5-super
The following extra packages will be installed:
  firebird2.5-common firebird2.5-common-doc firebird2.5-dev firebird2.5-server-common libfbclient2 libib-util
Suggested packages:
  libfbembed2.5 firebird2.5-examples firebird2.5-doc
The following NEW packages will be installed:
  firebird2.5-server-common firebird2.5-super
The following packages will be upgraded:
  firebird2.5-common firebird2.5-common-doc firebird2.5-dev libfbclient2 libib-util
5 upgraded, 2 newly installed, 0 to remove and 21 not upgraded.
Need to get 5,442kB of archives.
After this operation, 11.3MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Run Code Online (Sandbox Code Playgroud)

或者,如果您有多个 cpu(双核或 SMP 机器)并需要SMP 支持,请安装 Classic 或 Super Classic

sudo apt-get install firebird2.5-classic
Run Code Online (Sandbox Code Playgroud)

或者

sudo apt-get install firebird2.5-superclassic
Run Code Online (Sandbox Code Playgroud)

安装后需要配置包

sudo dpkg-reconfigure firebird2.5-super
Run Code Online (Sandbox Code Playgroud)

安装示例和开发文件

sudo apt-get install firebird2.5-examples firebird2.5-dev 
Run Code Online (Sandbox Code Playgroud)

employee.fdb 存档将在此目录下 /usr/share/doc/firebird2.1-examples/examples/empbuild/

cd /usr/share/doc/firebird2.5-examples/examples/empbuild/
sudo gunzip employee.fdb.gz
sudo chown firebird.firebird employee.fdb
sudo mv employee.fdb /var/lib/firebird/2.5/data/
Connect to database using the isql-fb console


$ isql-fb
SQL> connect "/var/lib/firebird/2.5/data/employee.fdb " user 'SYSDBA' password 'SYSDBApassword';
Run Code Online (Sandbox Code Playgroud)

在 2.5 中使用经典或超经典时,始终使用 localhost: 在 db 路径前面,这样锁定文件和共享内存段将归“firebird”用户所有。另一种选择是将自己添加到 firebird 组

$ sudo adduser `id -un` firebird
Run Code Online (Sandbox Code Playgroud)

然后连接到超经典或经典中的数据库

$ isql-fb
SQL> connect "localhost:/var/lib/firebird/2.5/data/employee.fdb " user 'SYSDBA' password 'SYSDBApassword';
Run Code Online (Sandbox Code Playgroud)

如果一切正常,那么您将收到有关连接的数据库和用户并准备使用 sql 提示的消息

Database:  "/var/lib/firebird/2.5/data/employee.fdb ", User: SYSDBA
SQL> 
Run Code Online (Sandbox Code Playgroud)

现在您可以检查服务器版本和表格

SQL> show tables;
       COUNTRY                                CUSTOMER
       DEPARTMENT                             EMPLOYEE
       EMPLOYEE_PROJECT                       JOB
       PROJECT                                PROJ_DEPT_BUDGET
       SALARY_HISTORY                         SALES

SQL> show version;
ISQL Version: LI-V2.5.0.* Firebird 2.5
Server version:
Firebird/linux Intel (access method), version "LI-V2.5.0.* Firebird 2.5"
Firebird/linux Intel (remote server), version "LI-V2.5.0.* Firebird 2.5/tcp (eeepc)/P11"
Firebird/linux Intel (remote interface), version "LI-V2.5.0.* Firebird 2.5 Release Candidate 2/tcp (eeepc)/P11"
on disk structure version 11.1
Run Code Online (Sandbox Code Playgroud)

创建新数据库

SQL> create database "/var/lib/firebird/2.5/data/first_database.fdb" user 'SYSDBA' password 'SYSDBAPASSWORD';
SQL> connect "/var/lib/firebird/2.5/data/first_database.fdb" user 'SYSDBA' password 'masterkey';
Commit current transaction (y/n)?y
Committing.
Database:  "/var/lib/firebird/2.5/data/first_database.fdb", User: SYSDBA
SQL>
Run Code Online (Sandbox Code Playgroud)

如果你想创建一个简单的表,然后插入 1-2 行并从中选择这里是一个例子

SQL> CREATE TABLE TEST (ID INT NOT NULL PRIMARY KEY, NAME VARCHAR(20));
SQL> show tables;
       TEST
SQL> INSERT INTO TEST VALUES (1, 'John');
SQL> INSERT INTO TEST VALUES (2, 'Joe');
SQL> select * from test;

          ID NAME                 
============ ==================== 
           1 John                 
           2 Joe 
Run Code Online (Sandbox Code Playgroud)

要退出 isql-fb 控制台,请输入 quit

SQL> quit
CON>; 
Run Code Online (Sandbox Code Playgroud)

对于一个好的开源 GUI 管理工具,您可以检查 ubuntu 存储库中包含的flarobin 管理工具可以通过一个简单的安装

sudo apt-get install flamerobin
Run Code Online (Sandbox Code Playgroud)

然后从菜单 Applications->Programming-> FlameRobin使用它

要将 firebird 与 php 一起使用,您将需要 php5 驱动程序

sudo apt-get install php5-interbase libapache2-mod-php5
sudo php5enmod interbase
sudo /etc/init.d/apache2 restart
Run Code Online (Sandbox Code Playgroud)

接下来如果你需要安装一个像 Firebird Web Admin 这样的 php 管理工具

sudo apt-get install git-core
git clone git://github.com/mariuz/firebirdwebadmin.git 
mv firebirdwebadmin /var/www/html/firebirdwebadmin
Run Code Online (Sandbox Code Playgroud)

并在浏览器中加载它http://localhost/firebirdwebadmin