How To Install SQLite3 On Mac

SQLite is a popular embed relational database. It can be used in both mobile device and personal computer. This article will tell you how to install and manage it in Mac.

1. Install SQLite3 On Mac.

  1. Download the SQLite zip file from SQLite official website.
  2. Then unzip the download file into a local folder such as /Users/zhaosong/Documents/WorkSpace/tool/sqlite-tools.
  3. Now the SQLite server has been installed, it do not need any installation.

2. Start SQLite Server.

  1. Open a terminal and CD to the SQLite file unzip folder.
  2. Execute sqlite3 in command line, when you see below messages, the SQLite server has been started.
    192:sqlite-tools zhaosong$ sqlite3
    SQLite version 3.23.1 2018-04-10 17:39:29
    Enter ".help" for usage hints.
    Connected to a transient in-memory database.
    Use ".open FILENAME" to reopen on a persistent database.
    sqlite>
  3. Now click Finder —> Go —> Applications to open MacOS application folder. And click Utilities —> Activity Monitor to open the activity monitor. You can find the sqlite3 process in this window.
    open mac os terminal in applications
    macos activity monitor

3. Stop SQLite Server.

Stop sqlite server is very easy, just in the opened terminal execute .quit command to stop the server. Then the SQLite process will also disappear in the activity monitor.

sqlite> .quit

4. Install SQLite Studio.

SQLite save all data of one database in a .db file. It is a binary file. So if you want to create more database, you need to create more .db file.

SQLite Studio is just a visual tool that can help you to manage SQLite database, includes create table, view etc.

  1. Go to SQLite Studio download page to download the latest version.
  2. Open the downloaded zip file and click the InstallSQLiteStudio-3.2.1.app icon to install it.
  3. But because the installer is not downloaded from App Store, so you may encounter errors which said can not open it.
  4. Click System Preferences —> Security & Privacy¬†then click Open Anyway button to open the SQLite Studio installer. Below picture do not contains the button, because i have already click the button before. If you install SQLite Studio for the first time, the Open Anyway button will be shown.
    open unauthorized mac executable software
  5. After the installation process, you can find the SQLiteStudio icon in Finder —> Go —-> Applications folder.
READ :   How To Merge Disk Partitions In Mac

5. Use SQLite Studio To Manage SQLite Server Database.

5.1 Create SQLite Database File.

  1. Click MacOS Applications —> SQLite Studio app icon to open it.
    macos finder go applications sqlite studio
  2. Click Database —> Add a database menu item to create a new SQLite database.
    sqlite studio database add a database menu item
  3. Because SQLite use one binary file to store one database data, so click the green plus icon in the popup window to add a new SQLite database file. To manage exist database file, just click the open folder button to browse the exist database file.
    click green plus icon to add a new sqlite database fileinput new sqlite database file name
  4. Click Test connection button to test whether the database can be connected or not.
  5. If all test passed, just click OK button to save the database file.

5.2 Create Table Use SQLite Studio.

  1. Right click the SQLite database just created, and click Create a table menu item in the popup menu list.
    sqlite studio create table in database
  2. Input table name in the text box. And click Commit structure changes icon ( green checkbox button at top bar ) to save the changes.
    sqlite studio add table and commit structure changes
  3. Click the Add column (Ins) icon button to add a table column.
    sqlite studio add column (ins) icon
  4. Input the column name and select the column data type. Check whether the column is Primary Key, Unique or Not Null checkbox.
    sqlite studio add id column
  5. If you want the table id column value auto increment, you can click the Configure button after the Primary Key and check Autoincrement checkbox, click Apply button to save.
    sqlite studio edit table column autoincrement checkbox
(Visited 275 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.