Ubuntu 下 firebird 數據庫的安裝和配置
1、簡介
本文主要是 Ubuntu 下 firebird 數據庫的安裝和目錄遷移,同樣適用於 Debian
系統:Ubuntu 20.0.4
firebird:3.0
注意:文中運行的命令基本上需要管理員權限
2、安裝 firebird
以下包可以按照需要安裝
安裝 firebird 服務器
apt install firebird3.0-server
只安裝 firebird 數據庫管理工具 gbak 和 isql-fb
apt install firebird3.0-server-core
用c/c++等 開發 firebird 客戶端
apt install firebird-dev
3、配置 firebird 服務器
停止 firebird 服務,終端輸入 systemctl stop firebird3.0
編輯 /etc/firebird/3.0/firebird.conf 文件
DatabaseAccess = Full
表示所有目錄的數據庫都可以訪問
DatabaseAccess = None
表示只有“別名數據庫”可以訪問
選擇默認即可
RemoteAccess = true
允許遠程訪問,建議開啓,要不然很多都操作不了
RemoteBindAddress = localhost
遠程訪問地址綁定,有非本機(127.0.0.1)訪問需求的,把這行註釋掉加#,建議註釋掉
其它設置可以查看 /etc/firebird/3.0/firebird.conf 文件,裏面有詳細的說明
開啓 firebird 服務,終端輸入 systemctl start firebird3.0,設置完畢
4、配置 firebird 數據庫別名
編輯 /etc/firebird/3.0/databases.conf 文件,按照文件裏這幾行例子寫就行了
big 是別名 = 文件路徑
big = /databases/bigdb.fdb
{
LockMemSize = 32M # We know that bigdb needs a lot of locks
LockHashSlots = 19927 # and big enough hash table for them
}
注意數據庫的讀寫權限和組都要設置爲 firebird
5、使用 gbak 備份和恢復數據
備份數據庫,例如備份本地別名爲 myfbdb 數據庫
gbak -user sysdba -password masterkey -b -verify -y ~/myfbdb.log 127.0.0.1:myfbdb ~/myfbdb.fbk
恢復數據庫,例如恢復本地別名爲 myfbdb 數據庫
gbak -user sysdba -password masterkey -c -verify -y ~/myfbdb.log ~/myfbdb.fbk 127.0.0.1:myfbdb
6、使用 isql-fb 管理數據庫
使用需要登錄的遠程數據庫的用戶和密碼爲參數
isql-fb -u sysdba -p masterkey
然後在 SQL 命令裏
connect 127.0.0.1:myfbdb;
就能連接數據庫了,連接本地數據庫也要用 127.0.0.1:myfbdb 的方式連接,要不然會有沒有讀寫權限的錯誤
或者用 sudo isql-fb 的方式運行,但是不建議。
還是用 IP 地址加“別名”的方式進行訪問比較好。