Ubuntu SQLite 壓縮包安裝配置 命令行安裝卸載

官網介紹

SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world. SQLite is built into all mobile phones and most computers and comes bundled inside countless other applications that people use every day.
SQLite是一個C語言庫,它實現了一個小型、快速、自包含、高可靠性、全功能的SQL數據庫引擎。SQLite是世界上使用最多的數據庫引擎。SQLite內置於所有移動電話和大多數計算機中,捆綁在人們每天使用的無數其他應用程序中。

使用壓縮包安裝

  • 下載 wget https://sqlite.org/2020/sqlite-tools-linux-x86-3310100.zip
    更多版本見:Sqlite 官網下載頁
  • 解壓至指定文件夾 sudo unzip sqlite-tools-linux-x86-3310100.zip -d /opt
  • 查看內容 ll /opt/sqlite-tools-linux-x86-3310100/
wuyujin@ubuntu18:~/Downloads/soft_debian/database$ ll /opt/sqlite-tools-linux-x86-3310100/
total 3960
drwxr-xr-x  2 root root    4096 1月  28 04:27 ./
drwxr-xr-x 11 root root    4096 2月   2 14:03 ../
-rwxr-xr-x  1 root root  560836 1月  28 04:25 sqldiff*
-rwxr-xr-x  1 root root  987012 1月  28 04:27 sqlite3*
-rwxr-xr-x  1 root root 2496032 1月  28 04:26 sqlite3_analyzer*
wuyujin@ubuntu18:~/Downloads/soft_debian/database$

可以看到sqlite是極度精簡的。

  • 設置環境變量
    修改/etc/profile,添加以下設置:
# SQLite
export SQLITE_HOME=/opt/sqlite-tools-linux-x86-3310100
export PATH=${SQLITE_HOME}/bin:$PATH

重啓使最新配置生效。

  • 測試環境變量
wuyujin@ubuntu18:~$ sqlite3 --version
3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2alt1
wuyujin@ubuntu18:~$ 
wuyujin@ubuntu18:~$ sqlite3 --help
Usage: sqlite3 [OPTIONS] FILENAME [SQL]
FILENAME is the name of an SQLite database. A new database is created
if the file does not previously exist.
OPTIONS include:
   -ascii               set output mode to 'ascii'
   -bail                stop after hitting an error
   -batch               force batch I/O
   -column              set output mode to 'column'
   -cmd COMMAND         run "COMMAND" before reading stdin
   -csv                 set output mode to 'csv'
   -echo                print commands before execution
   -init FILENAME       read/process named file
   -[no]header          turn headers on or off
   -help                show this message
   -html                set output mode to HTML
   -interactive         force interactive I/O
   -line                set output mode to 'line'
   -list                set output mode to 'list'
   -lookaside SIZE N    use N entries of SZ bytes for lookaside memory
   -mmap N              default mmap size set to N
   -newline SEP         set output row separator. Default: '\n'
   -nullvalue TEXT      set text string for NULL values. Default ''
   -pagecache SIZE N    use N slots of SZ bytes each for page cache memory
   -quote               set output mode to 'quote'
   -separator SEP       set output column separator. Default: '|'
   -stats               print memory stats before each finalize
   -version             show SQLite version
   -vfs NAME            use NAME as the default VFS
wuyujin@ubuntu18:~$ 

SQLite使用

命令行安裝、卸載及安裝位置查詢

以下要用到的命令:

  • 安裝軟件 apt-get install xxxdpkg -i xxx.deb
  • 檢測軟件是否已安裝/查看軟件安裝位置 dpkg -L xxxdpkg-query -L xxx
  • 卸載軟件 apt-get remove xxxdpkg -r xxx.deb
    shell操作如下:
wuyujin@ubuntu18:~$ # 查詢:sqlite3是否安裝
wuyujin@ubuntu18:~$ dpkg -L sqlite3
dpkg-query: package 'sqlite3' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
wuyujin@ubuntu18:~$ 
wuyujin@ubuntu18:~$ # 安裝sqlite3
wuyujin@ubuntu18:~$ sudo apt-get install sqlite3
[sudo] password for wuyujin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  sqlite3-doc
The following NEW packages will be installed:
  sqlite3
0 upgraded, 1 newly installed, 0 to remove and 21 not upgraded.
Need to get 754 kB of archives.
After this operation, 2,481 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 sqlite3 amd64 3.22.0-1ubuntu0.2 [754 kB]
Fetched 754 kB in 1s (1,321 kB/s)
Selecting previously unselected package sqlite3.
(Reading database ... 177511 files and directories currently installed.)
Preparing to unpack .../sqlite3_3.22.0-1ubuntu0.2_amd64.deb ...
Unpacking sqlite3 (3.22.0-1ubuntu0.2) ...
Setting up sqlite3 (3.22.0-1ubuntu0.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
wuyujin@ubuntu18:~$ 
wuyujin@ubuntu18:~$ # 查詢sqlite3安裝位置
wuyujin@ubuntu18:~$ dpkg -L sqlite3
/.
/usr
/usr/bin
/usr/bin/sqldiff
/usr/bin/sqlite3
/usr/share
/usr/share/doc
/usr/share/doc/sqlite3
/usr/share/doc/sqlite3/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/sqlite3.1.gz
/usr/share/doc/sqlite3/changelog.Debian.gz
wuyujin@ubuntu18:~$ 
wuyujin@ubuntu18:~$ # 卸載sqliet3
wuyujin@ubuntu18:~$ sudo apt-get remove sqlite3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  sqlite3
0 upgraded, 0 newly installed, 1 to remove and 21 not upgraded.
After this operation, 2,481 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 177516 files and directories currently installed.)
Removing sqlite3 (3.22.0-1ubuntu0.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
wuyujin@ubuntu18:~$ 
wuyujin@ubuntu18:~$ # 再次查詢:sqlite3是否安裝
wuyujin@ubuntu18:~$ dpkg -L sqlite3
dpkg-query: package 'sqlite3' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
wuyujin@ubuntu18:~$ 

可以看到使用包管理工具直接命令行操作是真的快。
但是如果操作的機器不能聯網,那也只能選第一種方案,手動下載壓縮包,解壓配置運行等。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章