Re-setting up from a failed db install.

Something on my Pi went south, iv managed to get it up and running again but im getting an error trying to load emoncms

Table 'emoncms1.users' doesn't exist
Fatal error: Call to a member function fetch_array() on a non-object in /var/www/emoncms/db.php on line 66

This is not surprising as iv had to install mysql from scratch and create the DB. But i thought the emoncms should create the DB tables if not found...  Is this not so.?

any ideas.. Thanks.

 

jb79's picture

Re: Re-setting up from a failed db install.

Did it allready worked or not, so is there any important data you need in the existing emoncms-Mysql database?

Are the database settings (/var/www/emoncms/settings.php) correct?

 

You can only try to delete the emoncms directory (with all included files in it) and the emoncms database im mysql. After that reinstall emoncms: http://openenergymonitor.org/emon/emoncms/installing-ubuntu-debian-pi

Then continue with the install here: http://wiki.openenergymonitor.org/index.php?title=Raspberry_Pi#RFM12BPi_...

 

robw's picture

Re: Re-setting up from a failed db install.

Thanks for that..  It was all working and some how the mysql got corrupt..  Iv removed it and reinstalled it and all seems to be ok now.. phpmadmin seems to work fine and i can see other dbs iv got on there..

just emoncms does not work.. 

The /var/......./settings.php are the same / tried a new db name that iv created eg step8  just it still fails. The error seems to point to the users table not the fact it cant get to the db..

Right just changed the settings file to a dummy database (thats does not exsist)

Warning: mysqli::mysqli(): (42000/1049): Unknown database 'emoncms11111' in /var/www/emoncms/db.php on line 41
Warning: mysqli::query(): Couldn't fetch mysqli in /var/www/emoncms/db.php on line 59
Warning: db_query(): Couldn't fetch mysqli in /var/www/emoncms/db.php on line 60
Fatal error: Call to a member function fetch_array() on a non-object in /var/www/emoncms/db.php on line 66

So that seems to point to the fact it cant see the db.

So edit to the correct db..

Table 'emoncms.users' doesn't exist
Fatal error: Call to a member function fetch_array() on a non-object in /var/www/emoncms/db.php on line 66

This seems to say the db is ok but the tables arnt there..

Any ideas.

TrystanLea's picture

Re: Re-setting up from a failed db install.

is $dbtest = true; in settings.php? it may be worth trying to insert this:

db_schema_setup(load_db_schema());

at line 29 of index.php

opening an emoncms page in the browser and then removing that line again, this will force a db update.

Trystan

robw's picture

Re: Re-setting up from a failed db install.

Thanks Trystan..

Seems the pi goes through memory cards quickly.. Set up a new card on the 28/12 and it ate its self today at 1012.

These are not cheap cards, EG sandisk cards. although from old cameras currently but they have not written millions of photos to them.

Anyway thanks again and the command does work.

nbates's picture

Re: Re-setting up from a failed db install.

I've gone through two cards already myself since mid-December. I'm hoping it was a bad power supply - I've just changed plugs and I'm now doing daily backups of the database. It doesn't really take that long to get a system going from scratch with the pre-made SD card image though.

Nick

edllew's picture

Re: Re-setting up from a failed db install.

I am on my fourth SD card and 2nd Raspberry Pi in the past month or so, trying to get emoncms to run stably.  I tried out 3 or 4 power supplies. 

Things would start out okay after a fresh OS and emoncms install.  The system load average as reported by "uptime" would start at about 2.0, but after a couple days would be up around 4 to 5, and about then the system would crash.  This all while running only emoncms.  On restart all it would give was I/O errors.  Some of the cards could be re-formatted and used again, but some I couldn't recover at all.

This high system load suggests to me that processes were waiting on I/O.  Which was presumably SD card access.

Two of the SD cards were Kingston micro-SD 8GB class 4.  Somewhere here I saw a note that suggested the performance of Kingston SD cards might not be good.  I agree. 

My fourth card which I just setup today is a Transcend class 10 8GByte, running in a 512MByte Pi rather than the 256MByte Pi I started with.  So far so good.  The power supply is now a linear bench power supply rather than a cheaper USB power supply.  Response is fast at the console compared to the other cards, and system load average remains below 0.5.

So I am hopeful, but won't trust that I have a good system until it works for a few more days.

I know little about MySQL and databases, but I do wonder if there is some performance optimization that could be done.  Time to do some reading.

On the plus side, I have gotten quite proficient at setting up Raspberry Pi's, and of course am enjoying the use of the whole OpenEnergyMonitor system.

-Ed

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.