Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get a "sqlite3: not found" error on a rooted Nexus One when I try to open a database using the adb shell?

# sqlite3 /data/data/com.moodme.android/databases/moodme
sqlite3 /data/data/com.moodme.android/databases/moodme
sqlite3: not found
like image 329
Julian A. Avatar asked Sep 05 '10 07:09

Julian A.


3 Answers

As an alternative (may not be secure or even good idea though) you can always upload the sqlite3 binary to /system/bin this worked for me:

First lets mount /system/ to allow read/write (rw)

$ adb shell
$ su
# mount -o remount,rw /system

in another terminal change directory (cd) to where sqlite3 is and lets push it

$ ls
sqlite3
$ adb push sqlite3 /sdcard/

Now back to the other shell lets copy and change permissions of the binary

# cat /sdcard/sqlite3 > /system/bin/sqlite3
# chmod 4755 /system/bin/sqlite3

Now lets mount back /system/ as read only (ro)

# mount -o remount,ro /system

And now we can use sqlite3 from shell:

# sqlite3 /data/data/com.telly/databases/fun.db
SQLite version 3.7.4
Enter ".help" for instructions
sqlite> .tables
android_metadata  lulz               

Note: I'm using the sqlite3 binary that comes with "SuperOneClickv1.6.5-ShortFuse"

You can always pull sqlite3 binary from emulator:

Start an emulator and then from a terminal

$ adb pull /system/xbin/sqlite3

If you are lazy like me you can download one right here for ICS or before or for Jelly Bean and later here

Make sure to use the proper one for your Android version as you may get eloc_library[1306]: 14446 cannot locate 'sqlite3_enable_load_extension'... or similar errors on execute

like image 138
eveliotc Avatar answered Nov 12 '22 14:11

eveliotc


On the Android emulator, sqlite3 is in /system/xbin. There is no /system/xbin on a Nexus One (Android 2.2). Hence, I suspect that sqlite3 is not installed on the Nexus One.

like image 42
CommonsWare Avatar answered Nov 12 '22 16:11

CommonsWare


From the answer of evelio, I had problem to push the sqlite3 file to /system/bin. So, instead, I have pushed it to the /sdcard.

In this thread I found the right Solution (answer of Kila): How can I install sqlite3 on rooted NexusOne runs Gingerbread

$ adb push sqlite3 /sdcard/
$ adb shell
$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# dd if=/sdcard/sqlite3 of=/system/bin/sqlite3
# chmod 4755 /system/bin/sqlite3
# mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system 

It works on my Samsung Galaxy S II with 2.3.3.

like image 12
jiahao Avatar answered Nov 12 '22 16:11

jiahao