Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there an initialize Database script for switching to SQL, or am I just missing something? #310

Open
sysRoot opened this issue Sep 23, 2021 · 10 comments

Comments

@sysRoot
Copy link

sysRoot commented Sep 23, 2021

I recently installed HashOver, in a subdirectory and handled it with Caddy. All was working well until I enabled SQL. I think I missed a step possibly. Documentation is sparse.

HashOver: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mpcomdb.comments' doesn't exist 

It works wonderfully, except XML isn't really for me, I'd rather have everything centralized in Databases, in case for some reason I have to move servers or something, then all I have to move are my frontend/backend.

If I missed some sort of procedure, I am not aware... but the user is set appropriately, as is database and pw in secrets

        // OPTIONAL SQL INFORMATION

        // Type of database, sqlite or mysql
        protected $databaseType = 'mysql';

        // Database name
        protected $databaseName = 'mpcomdb';

        // SQL database host name
        protected $databaseHost = 'localhost';

        // SQL database port number
        protected $databasePort = '3306';

        // SQL database login user
        protected $databaseUser = 'topin';

        // SQL database login password
        protected $databasePassword = '[OMITTED]';

        // SQL database character set
        protected $databaseCharset = 'utf8';

All seems to check out fine, user has ALL Privileges on database.

@jacobwb
Copy link
Owner

jacobwb commented Sep 23, 2021

HashOver will automatically create the table it needs to store the comments, but it will not create the database. This is why the database name is configurable in the secrets.php file. Perhaps the database should be automatically created, but I felt that was too intrusive, so it doesn't get automatically created right now.

All you should need to do is create the mpcomdb database you set in the secrets.php file.

@sysRoot
Copy link
Author

sysRoot commented Sep 23, 2021

Fair enough. I didn't mean create... perhaps SEED was a better word. It might have had to do with the fact that I dropped the database as a testing procedure.

So I re-cloned hashover, moved it to the same directory after removing everything, and reset it up. Sorry, should've tried that first.
It works great in my nextJS app btw.
Clean and concise... way better than running some other alternatives I tried :)

@sysRoot sysRoot closed this as completed Sep 23, 2021
@sysRoot
Copy link
Author

sysRoot commented Sep 23, 2021

Well I thought it was fixed, after creating everything from scratch but no. mpcomdb.comments not found still persists, when I thought it was working, it had saved to XML format agan

@sysRoot sysRoot reopened this Sep 23, 2021
@sysRoot
Copy link
Author

sysRoot commented Sep 23, 2021

Well I thought it was fixed, after creating everything from scratch but no. mpcomdb.comments not found still persists, when I thought it was working, it had saved to XML format agan

To emphasize setup, I have a properly chowned directory at /var/www/html/hoc, owned by caddy:caddy and executed via the caddy fast_cgi directive under a handler directive. I created the table first, assigned privileges, git cloned, moved the hoc directory from my home folder under /home/thero/hoc to /var/html/www/hoc and recursively chowned it again, edited secrets.php, went to the admin of HashOver at meaningpoetry.com/hoc/admin and tried setting it to SQL format. These are the steps I took pretty much to the bone, to setup HashOver. I don't think it has anything to do with Caddy, and the same user writes fine to all my other databases. Yes, I know I should have different SQL users, that is something to address in code/config cleanups later on, but for now it's fine and works, since everything is local. Assigned ALL PRIVILEGES to topin on mpcomdb and double checked. Have dropped the database and recreated it numerous times and have tried git clone from fresh each time, the only thing reused are values from secrets.php

@jacobwb
Copy link
Owner

jacobwb commented Sep 24, 2021

I just tried for myself to clone HashOver and create the database from scratch to see if it works, and everything worked.

Are you using actual MySQL or some other derivative? That could cause problems if the syntax is incompatible.

Have you tried creating the database, and comments and page-info tables manually to see if it stops complaining?

I posted the schema here: #247 (comment)

@sysRoot
Copy link
Author

sysRoot commented Sep 24, 2021

I am using MariaDB to be specific, which I thought was a more or less implementation of the MySQL specification I will try processing the info manually to see. Will report back

@sysRoot
Copy link
Author

sysRoot commented Sep 24, 2021

It immediately started working after plugging in the schema to the mariadb terminal.

@jacobwb
Copy link
Owner

jacobwb commented Sep 24, 2021 via email

@sysRoot
Copy link
Author

sysRoot commented Sep 26, 2021

Thank you for your help. The system is awesome and clean, plus the dark theme goes well with the default mode of my site. I would be happy to see the implementation, as it seems MariaDB seems very common across a lot of hosts, from past experience. I only went with it as it is what was recommended by ArchWiki

@da2x
Copy link
Contributor

da2x commented Dec 4, 2021

Great! That probably means that the table creation statement isn't quite compatible with MariaDB.

It is compatible with MariaDB. HashOver creates the tables just fine as long as it has the required permissions. There’s something else wrong.

I had problems in the beginning because I didn’t know that I had to change the data-format setting as well as the databaseType secret. Maybe this was your problem too, @sysRoot? You don’t mention it in your initial post. I’ll address it in the SQL Setup documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants