Installation Sqlite3 on CentOS 7.9

一、Installation Sqlite3 on CentOS 7.9

1 地址

 

2 wget 下载

wget https://www.sqlite.org/2022/sqlite-autoconf-3390400.tar.gz

3 解压包

tar -zxvf sqlite-autoconf-3390400.tar.gz -C /opt/

4 进入文件包

cd /opt/sqlite-autoconf-3390400

5 检测安装路径

./configure --prefix=/usr/local/sqlite3

6 编译&安装

make && make install

安装完后可以看见如下提示

这段内容显示了sqlite3的安装路径:/usr/local/sqlite3/lib。

特别注意 add LIBDIR to the 'LD_LIBRARY_PATH' environment variable,这是sqlite建议添加环境变量

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/sqlite3/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

7 增加环境变量

vim /etc/profile
export LD_LIBRARY_PATH=/usr/local/sqlite3/lib
# 使配置文件生效
source /etc/profile

8 查看是否安装成功

ls -l /usr/local/sqlite3/lib/*sqlite*
ls -l /usr/local/sqlite3/include/*sqlite*

9 替换系统中旧的sqlite

# 把旧的sqlite3改个名字
mv /usr/bin/sqlite3  /usr/bin/sqlite3_old
# 设置软链接
ln -s /usr/local/sqlite3/bin/sqlite3   /usr/bin/sqlite3
echo "/usr/local/sqlite3/lib" > /etc/ld.so.conf.d/sqlite3.conf
# 动态链接库管理命令
ldconfig

10 检测版本

[root@ecs-65685 bin]# sqlite3
SQLite version 3.39.4 2022-09-29 15:55:41
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> 
sqlite> .quit

# 查看sqlite3版本
[root@ecs-65685 bin]# sqlite3 --version
3.39.4 2022-09-29 15:55:41 a29f9949895322123f7c38fbe94c649a9d6e6c9cd0c3b41c96d694552f26b309

11 帮助命令

[root@ecs-65685 ~]# 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:
   -A ARGS...           run ".archive ARGS" and exit
   -append              append the database to the end of the file
   -ascii               set output mode to 'ascii'
   -bail                stop after hitting an error
   -batch               force batch I/O
   -box                 set output mode to 'box'
   -column              set output mode to 'column'
   -cmd COMMAND         run "COMMAND" before reading stdin
   -csv                 set output mode to 'csv'
   -deserialize         open the database using sqlite3_deserialize()
   -echo                print inputs 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
   -json                set output mode to 'json'
   -line                set output mode to 'line'
   -list                set output mode to 'list'
   -lookaside SIZE N    use N entries of SZ bytes for lookaside memory
   -markdown            set output mode to 'markdown'
   -maxsize N           maximum size for a --deserialize database
   -memtrace            trace all memory allocations and deallocations
   -mmap N              default mmap size set to N
   -newline SEP         set output row separator. Default: '\n'
   -nofollow            refuse to open symbolic links to database files
   -nonce STRING        set the safe-mode escape nonce
   -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'
   -readonly            open the database read-only
   -safe                enable safe-mode
   -separator SEP       set output column separator. Default: '|'
   -stats               print memory stats before each finalize
   -table               set output mode to 'table'
   -tabs                set output mode to 'tabs'
   -version             show SQLite version
   -vfs NAME            use NAME as the default VFS
   -zip                 open the file as a ZIP Archive

 

posted @ 2022-10-09 13:37  娇小赤雅  阅读(1044)  评论(0编辑  收藏  举报