专治不带脑 發表於 2022-10-9 13:37:00

Installation Sqlite3 on CentOS 7.9

<h3><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 18px">一、Installation Sqlite3 on CentOS 7.9</span></h3>
<h4><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>1</strong> 地址</span></h4>
<ul>
<li><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">https://www.sqlite.org</span></li>
<li><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">https://github.com/sqlite/sqlite</span></li>
<li><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">https://www.sqlite.org/2022/sqlite-autoconf-3390400.tar.gz</span></li>
</ul>
<p><img src="https://img2022.cnblogs.com/blog/2412541/202210/2412541-20221009003042406-827608878.png" alt="" height="493" width="520"></p>
<p><img src="https://img2022.cnblogs.com/blog/2412541/202210/2412541-20221009003101525-1395107870.png" alt="" height="493" width="520"></p>
<p>&nbsp;</p>
<p id="1665246656704"></p>
<p id="1665246650268"></p>
<h4><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>2</strong> wget 下载</span></h4>
<pre class="language-bash highlighter-hljs"><code>wget https://www.sqlite.org/2022/sqlite-autoconf-3390400.tar.gz</code></pre>
<h4><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>3</strong> 解压包</span></h4>
<pre class="language-bash highlighter-hljs"><code>tar -zxvf sqlite-autoconf-3390400.tar.gz -C /opt/</code></pre>
<h4><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>4</strong> 进入文件包</span></h4>
<pre class="language-bash highlighter-hljs"><code>cd /opt/sqlite-autoconf-3390400</code></pre>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><img src="https://img2022.cnblogs.com/blog/2412541/202210/2412541-20221009000611481-1841121844.png" alt="" height="139" width="600"></span></p>
<p id="1665245177205"></p>
<h4><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>5 </strong>检测安装路径</span></h4>
<pre class="language-bash highlighter-hljs"><code>./configure --prefix=/usr/local/sqlite3</code></pre>
<h4><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>6</strong> 编译&amp;安装</span></h4>
<pre class="language-bash highlighter-hljs"><code>make &amp;&amp; make install</code></pre>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">安装完后可以看见如下提示</span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">这段内容显示了sqlite3的安装路径:/usr/local/sqlite3/lib。</span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">特别注意 add LIBDIR to the '<span style="color: rgba(228, 55, 233, 1)">LD_LIBRARY_PATH</span>' environment variable,这是sqlite建议添加<span style="color: rgba(228, 55, 233, 1)">环境变量</span>。</span></p>
<pre class="language-bash highlighter-hljs"><code>----------------------------------------------------------------------
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.
----------------------------------------------------------------------</code></pre>
<h4><span style="font-size: 16px; font-family: &quot;Microsoft YaHei&quot;"><strong>7</strong> 增加环境变量</span></h4>
<pre class="language-bash highlighter-hljs"><code>vim /etc/profile
export LD_LIBRARY_PATH=/usr/local/sqlite3/lib
# 使配置文件生效
source /etc/profile</code></pre>
<h4><span style="font-size: 16px; font-family: &quot;Microsoft YaHei&quot;"><strong>8</strong> 查看是否安装成功</span></h4>
<pre class="language-bash highlighter-hljs"><code>ls -l /usr/local/sqlite3/lib/*sqlite*
ls -l /usr/local/sqlite3/include/*sqlite*</code></pre>
<h4><span style="font-size: 16px; font-family: &quot;Microsoft YaHei&quot;"><strong>9</strong> 替换系统中旧的sqlite</span></h4>
<pre class="language-bash highlighter-hljs"><code># 把旧的sqlite3改个名字
mv /usr/bin/sqlite3/usr/bin/sqlite3_old
# 设置软链接
ln -s /usr/local/sqlite3/bin/sqlite3   /usr/bin/sqlite3
echo "/usr/local/sqlite3/lib" &gt; /etc/ld.so.conf.d/sqlite3.conf
# 动态链接库管理命令
ldconfig</code></pre>
<h4><span style="font-size: 16px; font-family: &quot;Microsoft YaHei&quot;"><strong>10</strong> 检测版本</span></h4>
<pre class="language-bash highlighter-hljs"><code># 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&gt;
sqlite&gt; .quit

# 查看sqlite3版本
# sqlite3 --version
3.39.4 2022-09-29 15:55:41 a29f9949895322123f7c38fbe94c649a9d6e6c9cd0c3b41c96d694552f26b309</code></pre>
<h4><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>11</strong> 帮助命令</span></h4>
<pre class="language-bash highlighter-hljs"><code># sqlite3 --help
Usage: sqlite3 FILENAME
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
   -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</code></pre>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/huaxiayuyi/p/16770739.html
頁: [1]
查看完整版本: Installation Sqlite3 on CentOS 7.9