简体   繁体   中英

working with sqlite3 in mac os x 10.9

I know that Mac OSx has pre-installed sqlite3.But when I am entering this command, when in /usr/bin directory, sqlite3 test.db i get this displayed on terminal..

Adityas-MacBook-Air:bin adityabahuguna$ sqlite3 test.db
SQLite version 3.7.13 2012-07-17 17:46:21
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

Its fine till now. But when i try to create a table by

sqlite> create table t(name text);

I always get this error:

Error: unable to open database "test.db": unable to open database file

This however does not occur when i directly use create table command without creating a new database. I want to figure out the way to create a new database (say test.db as above).

You're trying to create the database in /usr/bin where normal users don't have write access.

You can write to /usr/bin with root/sudo as suggested by Atul but that's not really something you should do.

Instead, specify a database path that is writable by your normal user, for example

sqlite3 ~/test.db

so the test.db gets created in your home directory.

you need to be logged in as root user to have create database privilege. you can become root user by following these steps: How to Become root user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM