system76 / beansbooks

A revolutionary cloud accounting platform designed for small and medium businesses.
129 stars 36 forks source link

Error reading session data, mysql_select_db parameter error #277

Open roberto-co opened 5 years ago

roberto-co commented 5 years ago

I have the following setup: Ubuntu 14.04 Php 5 Mysql 5.5 Apache2

I followed this guide along with the guide here in github README.

[https://blog.technerdservices.com/index.php/2015/03/tutorial-how-to-install-beansbooks-on-ubuntu-14-04/]

Session_Exception [ 1 ]: Error reading session data. [SID:(), name:session][Details: exception 'ErrorException' with message 'mysql_select_db() expects parameter 2 to be resource, boolean given' in /var/www/html/modules/database/classes/kohana/database/mysql.php:105 Stack trace: #0 [internal function]: Kohana_Core::error_handler(2, 'mysql_select_db...', '/var/www/html/m...', 105, Array) #1 /var/www/html/modules/database/classes/kohana/database/mysql.php(105): mysql_select_db('kohana', false) #2 /var/www/html/application/classes/database/mysql.php(75): Kohana_Database_MySQL->_select_db('kohana') #3 /var/www/html/modules/database/classes/kohana/database/mysql.php(430): Database_MySQL->connect() #4 /var/www/html/modules/database/classes/kohana/database.php(478): Kohana_Database_MySQL->escape('5c8ebb17bf6e53-...') #5 [internal function]: Kohana_Database->quote('5c8ebb17bf6e53-...') #6 /var/www/html/modules/database/classes/kohana/database/query.php(190): array_map(Array, Array) #7 /var/www/html/modules/database/classes/kohana/database/query/builder/select.php(413): Kohana_Database_Query->compile(Object(Database_MySQL)) #8 /var/www/html/modules/database/classes/kohana/database/query.php(228): Kohana_Database_Query_Builder_Select->compile(Object(Database_MySQL)) #9 /var/www/html/modules/database/classes/kohana/session/database.php(131): Kohana_Database_Query->execute(Object(Database_MySQL)) #10 /var/www/html/modules/database/classes/kohana/session/database.php(111): Kohana_Session_Database->_regenerate() #11 /var/www/html/system/classes/kohana/session.php(300): Kohana_Session_Database->_read(NULL) #12 /var/www/html/system/classes/kohana/session.php(125): Kohana_Session->read(NULL) #13 /var/www/html/modules/database/classes/kohana/session/database.php(74): Kohana_Session->__construct(Array, NULL) #14 /var/www/html/system/classes/kohana/session.php(54): Kohana_Session_Database->__construct(Array, NULL) #15 /var/www/html/application/classes/controller.php(45): Kohana_Session::instance() #16 /var/www/html/application/classes/controller/view.php(36): Controller->before() #17 /var/www/html/application/classes/controller/auth.php(24): Controller_View->before() #18 [internal function]: Controller_Auth->before() #19 /var/www/html/system/classes/kohana/request/client/internal.php(103): ReflectionMethod->invoke(Object(Controller_Auth)) #20 /var/www/html/system/classes/kohana/request/client.php(64): Kohana_Request_Client_Internal->execute_request(Object(Request)) #21 /var/www/html/system/classes/kohana/request.php(1154): Kohana_Request_Client->execute(Object(Request)) #22 /var/www/html/index.php(109): Kohana_Request->execute() #23 {main}]

I added some code to really see what the error kohana was throwing and that is what i showed here is what I added to show a detailed error:

} 321 catch (Exception $e) 322 { 323 // Error reading the session, usually 324 // a corrupt session. 325 throw new Session_Exception('Error reading session data.'. " [SID:".$id."(".$this->id()."), name:".$this->_name."][Details: " . $e . "]\n", NULL, Session_Exception::SESSION_CORRUPT); 326 } 327 328 if (is_array($data)) 329 { 330 // Load the data locally

Has anyone seen this error I've looked through all errors but haven't seen this yet.

Thanks,

roberto-co commented 5 years ago

Okay, so I opted to try to do install manually. I set my values in the config.php and now I get this error:

A fatal error has occurred: Session_Exception [ 1 ]: Error reading session data. [SID:(), name:session][Details: Database_Exception [ 1146 ]: Table 'beans.sessions' doesn't exist [ SELECT session_id FROM sessions WHERE session_id = '5c8ec2fad43bf0-65593355' LIMIT 1 ] ~ MODPATH/database/classes/kohana/database/mysql.php [ 194 ]] ~ SYSPATH/classes/kohana/session.php [ 325 ]

I figured okay, let me just manually run the sql file that is in install_files to create the tables.

When I do a show tables on my 'beans' database I get: | Tables_in_beans | +---------------------------+ | account_reconciles | | account_transaction_forms | | account_transactions | | account_types | | accounts | | entities | | entity_addresses | | form_lines | | form_taxes | | forms | | logs | | roles | | settings | | tax_items | | tax_payments | | taxes | | transactions | | users | +---------------------------+ 18 rows in set (0.00 sec)

mysql>

The sessions table really doesn't exist.

roberto-co commented 5 years ago

Okay, so I saw the sessions table missing, I created a table in my beans database:

CREATE TABLE (session_id INT)

Now I'm able to get HTML data back but it loads with a 404 error, I click on Dash and it runs through a series of updates...

Current Version 1.1 Start Upgrade Version 1.2

I click upgrade but it doesn't do anything. I'm getting closer to a solution, I'm documenting everything I do in case somebody else has this problem.

Thanks,

roberto-co commented 5 years ago

At this point I am unable to go from version 1.1.1 to version 1.2. I'm stuck at a page where it says Ready To Install.

I had a new problem and it was with sessions table not having the last_active column I had to add it manually:

mysql> ALTER TABLE sessions ADD COLUMN last_active DATE; Query OK, 0 rows affected (0.37 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql>

roberto-co commented 5 years ago

Beansbook index.php at the very bottom says I'm version: BeansBooks Version 1.5.2

However at the update screen I am 1.1.1

I'm a bit stuck now since the errors aren't very descriptive anymore now I just get "404 Error Unable to find a route to match the URI: index.php"

btkostner commented 5 years ago

@roberto-co Run this to create your sessions table:

CREATE TABLE `sessions` (
  `session_id` varchar(24) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_active` int(10) unsigned NOT NULL,
  `contents` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`session_id`),
  KEY `last_active` (`last_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
roberto-co commented 5 years ago

@btkostner thanks for the sql script. I was missing contents. I ran it...it created it nicely. I got to the page where it asks to Install, I gave it my db creds, then it went to the email portion i skipped it, it then went to the set up of the admin..it did it no problem..at the finalization screen I got hit with:

A fatal error has occurred: Database_Exception [ 1146 ]: Table 'beansbooks.settings' doesn't exist [ SHOW FULL COLUMNS FROM settings ] ~ MODPATH/database/classes/kohana/database/mysql.php [ 194 ]

So again I ran the database_structure.sql file..and it let me proceed.

It now is asking me to go through some updates, no big deal..I did them now I'm stuck at this part..I can't go to update 1.2 because it gives the error:

Error running update: Unexpected error when trying to create new prepaid asset account: Could not locate account type code: bankaccount

roberto-co commented 5 years ago

Looks like I have all my tables created but they are all empty. Do you happen to have the default data that is supposed to be inside each table? Can you provide that also please.

btkostner commented 5 years ago

@roberto-co Sadly that's a lot harder then it should be because it's all encrypted. I can't give you a secure snapshot with basic data in it.

roberto-co commented 5 years ago

I understand bummer. If a snapshot vdi isn't possible how about a fresh install mysql database? In theory I should have one already since i'm running the install but for whatever reason I'm having issues. I could stop the service drop the mysql database in and spin it up again?

if i run sudo ls /var/lib/mysql

I can see my beans database maybe I could get a hold of a copy of a freshly installed db? :)

bato3 commented 5 years ago

If you don't have any data in database, then fresh start is a good idea.

Fresh code + database. And don't forget to create a session table.

roberto-co commented 5 years ago

I will try again from scratch and create session table and circle back with my results. Thanks,

roberto-co commented 5 years ago

Tried again from scratch, no luck.

bato3 commented 5 years ago

what error now?

roberto-co commented 5 years ago

Error is same as before. It states i dont have account types.

I created a new database, set up config, i created sessions table set permissions ran the /install i set my db calues, smtp values, it asked me to create an admin then i went through a series of updates and then it got stuck woth the error about account types not being set up.

roberto-co commented 5 years ago

@bato3 have you had success installing beansbooks?

roberto-co commented 5 years ago

I see an init.php file in the directory application\classes\beans\setup\init.php where it lists out account_types and roles maybe I can manually insert all these values? it will take a while but I could do it if its worth a shot?

bato3 commented 5 years ago

settings table is created here: https://github.com/system76/beansbooks/blob/master/install_files/database_structure.sql Check is it created in DB, eg by PMA.

Do you remember what I write you on SO about PDO? It can be used for debug connection, but beansbooks require mysql(i) driver to run.

roberto-co commented 5 years ago

that is the problem, it doesn't create any of the tables when going through the install. So i manually have to run mysql >> source /var/www/html/install_files/database_structure.sql

Once i run this it creates the tables but they are all empty.

roberto-co commented 5 years ago

I dont see any of the insert statements that get the data into the tables.

bato3 commented 5 years ago

You probably need to use a combined approach. Create a database from the console from this file, delete all SQL content, and then run the WEB installation process.

roberto-co commented 5 years ago

Yep that is what I have been doing. I create the database like the README outlines. I manually generate the tables via the structure file. Then I run the WEB installation process it then complains that there are tables present. So i have to make sure the db is EMPTY, i run web install...it complains that sessions table doesn't exist. So i run the sessions sql provided. I run web install it continues...but it never creates the tables. So once i get passed a certain point i manually create the the tables and continue with install... While going through the upgrades it complains that there is no "account_types" defined in my account_types table so I insert the Bank Account type that i saw in the init file...it then complains about settings being empty..I create a settings insert statement found in the init file which is 'company_logo_data'...it then complains about more data that isn't present in the tables.

I think if i can get all the default data that goes into the tables I would be good.