Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: MrToga on June 07, 2022, 04:33:37 AM

Title: Mariadb
Post by: MrToga on June 07, 2022, 04:33:37 AM
Hello guys,

I'm currently trying to use mariadb but when I try to use sudo /urs/local/mysql/bin/mysql  I get this error :
Code: [Select]
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)
I found something here (https://sebhastian.com/mysql-error-2002/)
So I tried to run sudo /usr/local/etc/init.d/mysql start but I get this error :
Code: [Select]
sudo /usr/local/etc/init.d/mysql start
Starting MariaDB.220607 08:29:03 mysqld_safe Logging to '/home/tc/mysql/data/box.err'.
220607 08:29:03 mysqld_safe Starting mariadbd daemon with databases from /home/tc/mysql/data
sh: can't kill pid 5637: No such process
I also use beforehand sudo /usr/local/mysql/bin/mysqld_safe --user=root & it runs without error.

Any toughts ?
Title: Re: Mariadb
Post by: Rich on June 07, 2022, 09:46:35 AM
Hi MrToga
Code: [Select]
sudo /usr/local/etc/init.d/mysql start
Starting MariaDB.220607 08:29:03 mysqld_safe Logging to '/home/tc/mysql/data/box.err'.
220607 08:29:03 mysqld_safe Starting mariadbd daemon with databases from /home/tc/mysql/data
sh: can't kill pid 5637: No such process
That sounds like it tried to kill a nonexistent copy of mysql so multiple copies don't get started. I think you can
ignore that. Does this show that mysql started and is running:
Code: [Select]
ps aux PIPE grep mysql PIPE grep -v grepSorry, forum error. Replace the word  PIPE  with the  |  symbol.
Title: Re: Mariadb
Post by: MrToga on June 07, 2022, 09:52:55 AM
Hi Rich,

It shows 0 process containing mysql
Title: Re: Mariadb
Post by: tacpilot on June 07, 2022, 03:08:31 PM
Has been a very long time since I have done any DB stuff so I will just shoot from the hip
and see if any thing hits..

hope this helps
cheers  :)
Title: Re: Mariadb
Post by: MrToga on June 08, 2022, 06:03:31 AM
Update :

I think i've got a problem with my plugin because when I start mysqld I get an error that said I'm missing plugin (attached files). After some research I found out that you can see the plugin loaded using mysqlcheck (plugincheck.txt) but it seems to be some variable (at the end of the file).
I've also done what tacpilot said I checked the /init.d/mysql file I change some variable in the file for basedir and datadir like this :
Code: [Select]
basedir=/usr/local/mysql  and datadir=/home/tc/mysql/data I also modified the my.cnf file in /usr/local/etc/mysql/my.cnf I added :
Code: [Select]
[mysqld]
basedir=/usr/local/mysql
plugin_dir=/usr/local/mysql/lib/plugin
I don't understand what I am missing since the mariadb knoledge basis for installation only say to start mysqld (link : https://mariadb.com/kb/en/starting-and-stopping-mariadb-automatically/)
So in the end I'm still stuck.
Any toughts ?
Title: Re: Mariadb
Post by: Rich on June 08, 2022, 09:09:40 AM
Hi MrToga
... I also modified the my.cnf file in /usr/local/etc/mysql/my.cnf ...
According to the  plugincheck.txt  file you attached:
Quote
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
Title: Re: Mariadb
Post by: MrToga on June 08, 2022, 09:14:23 AM
Hi Rich,

After copying my.cnf file in /etc/ (I don't the other directory)

I still get the same error on mysqld
Title: Re: Mariadb
Post by: tacpilot on June 08, 2022, 09:24:30 AM
Sounds like you need to initialize a DB.
and make sure your permissions are set correctly for the mysql user.

You may need adjust user and paths for your system setup and needs.
This should be the general idea.

Code: [Select]
sudo mysql_install_db --user=mysql --basedir=/usr/local/mysql --ldata=/home/tc/mysql/data

sudo chown -R mysql:mysql /home/tc/mysql/data

Quote
After a fresh install of mysql (or after you delete /var/lib/mysql), you need to manually create the system tables via mysql_install_db. The mysql daemon will not do it for you on startup
Quote
Give mysql ownership and group priveleges with:
chown -R mysql /var/lib/mysql
chgrp -R mysql /var/lib/mysql

quotes referrence:
https://stackoverflow.com/questions/9083408/fatal-error-cant-open-and-lock-privilege-tables-table-mysql-host-doesnt-ex

some additional reading
https://forums.mysql.com/read.php?11,51024,91019

Hope this helps :)
Title: Re: Mariadb
Post by: Rich on June 08, 2022, 09:50:40 AM
Hi MrToga
I have a similar answer.

Run these 2 commands. Adjust  basedir  and  datadir  as needed:
Code: [Select]
sudo rm -R /var/lib/mysql/*
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Adapted from instructions found here:
https://imrecsige.dev/snippets/fix-mariadb-missing-tables-on-manjaro-arch-linux/

Same  install_db  command was suggested here:
https://stackoverflow.com/questions/69935085/mysql-mariadb-cant-open-and-lock-privilege-tables-table-mysql-servers-doesn
Title: Re: Mariadb
Post by: MrToga on June 08, 2022, 10:23:26 AM
Update :

After I've tried the two solution you gave me I got some problem.

With  tacpilot's solution I got an error from auth_pam_ tool that it didn't exist so I tried to install the extension linux-pam without any success and I also found some topic (https://www.linuxquestions.org/questions/slackware-14/mysql_install_db-mariadb-10-4-6-on-slackware64-current-is-not-working-4175656852/) to just delete a line in the script but it didn't work either.
And with Rich's solution I don't have /var/lib/mysql/ directory at all so in the end it's still the same as the first solution.

I attached the script (I deleted the part that was in the link above)  and the error hope you can find something.

(I also created mysql user using adduser I don't know if I can create a DB user like that maybe it's part of the problem I don't know)
Title: Re: Mariadb
Post by: Rich on June 08, 2022, 11:59:27 AM
Hi MrToga
... And with Rich's solution I don't have /var/lib/mysql/ directory ...
The  rm  command was just in case mysql had created any files there.

... I also use beforehand sudo /usr/local/mysql/bin/mysqld_safe --user=root & it runs without error.
That's basically what it says to do here:
http://tinycorelinux.net/13.x/armv7/tcz/mariadb.tcz.info
Title: Re: Mariadb
Post by: tacpilot on June 08, 2022, 12:09:45 PM
Server errors forcing this across multiple posts..

Core concepts to understand.
System users and mysql users are not the same..
They can be the same name but, their scope of authority are not the same.

Mariadb is installed on the system and needs to be run as a user.
It is recommended to Not run it as system root and is most often run as mysql
If the system user mysql was not be created automatically then adding it manually is required
Title: Re: Mariadb
Post by: tacpilot on June 08, 2022, 12:15:55 PM
this forum is ridiculous .. taking 20 mins for a simple reply due to server errors ..
will continue in a bit before I get banned for DOS
Title: Re: Mariadb
Post by: tacpilot on June 08, 2022, 12:24:49 PM
set this user in your /etc/ init.d/mysql
In that script and make sure mysql starts with mysql user
Code: [Select]
su - mysql -s /bin/bash -c "mysqld_safe > /dev/null &"
Title: Re: Mariadb
Post by: tacpilot on June 08, 2022, 12:25:26 PM
Now create the path for where your DB will reside
and set user permissions
Code: [Select]
mkdir -p /home/tc/mysql/data
sudo chown mysql:mysql /home/tc/mysql/data
sudo chmod 750 /home/tc/mysql/data

This should get your system inline to run mysql

You can have many databases on a system and
each one can have its own authenticated user base and admins
Data base users and admins are configured through mysql

Now you need to create and activate a database
Code: [Select]
sudo mysql_install_db --user=mysql --basedir=/usr/local/mysql --ldata=/home/tc/mysql/data
The error log shows there may be path and/or command conflicts that may need further attention.
Title: Re: Mariadb
Post by: tacpilot on June 08, 2022, 12:26:36 PM
Some additional reading:

https://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/data-directory-initialization.html

https://dev.mysql.com/doc/refman/8.0/en/user-names.html
Title: Re: Mariadb
Post by: MrToga on June 09, 2022, 08:10:48 AM
Update :

After I've done what you told me it worked !
I just needed to rearranged some permissions on some directory and now my mariadb works fine with phpMyAdmin

Thanks you very much
Title: Re: Mariadb
Post by: tacpilot on June 09, 2022, 08:27:59 AM
Excellent news ... glad to hear you got it working..
Cheers  :)