WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Mariadb  (Read 2114 times)

Offline MrToga

  • Full Member
  • ***
  • Posts: 142
Mariadb
« on: June 07, 2022, 01: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 ?
It's fine

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Mariadb
« Reply #1 on: June 07, 2022, 06: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.

Offline MrToga

  • Full Member
  • ***
  • Posts: 142
Re: Mariadb
« Reply #2 on: June 07, 2022, 06:52:55 AM »
Hi Rich,

It shows 0 process containing mysql
It's fine

Offline tacpilot

  • Newbie
  • *
  • Posts: 30
Re: Mariadb
« Reply #3 on: June 07, 2022, 12: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..

  • reminder that the root/admin of the DB is not the same as the root/admin of your system
  • /etc/init.d/mysql start is an init script that may establish some prerequisite before actually calling mysql
  • looking at the init script may help point you in the right direction
  • making sure all the correct user groups are setup and all appropriate permissions are in place
  • checking your logs at /home/tc/mysql/data/box.err may detail the errors more clearly
hope this helps
cheers  :)
Never limit your creativity by the imagination of others.

Offline MrToga

  • Full Member
  • ***
  • Posts: 142
Re: Mariadb
« Reply #4 on: June 08, 2022, 03: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 ?
It's fine

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Mariadb
« Reply #5 on: June 08, 2022, 06: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

Offline MrToga

  • Full Member
  • ***
  • Posts: 142
Re: Mariadb
« Reply #6 on: June 08, 2022, 06: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
It's fine

Offline tacpilot

  • Newbie
  • *
  • Posts: 30
Re: Mariadb
« Reply #7 on: June 08, 2022, 06: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 :)
« Last Edit: June 08, 2022, 06:40:48 AM by tacpilot »
Never limit your creativity by the imagination of others.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Mariadb
« Reply #8 on: June 08, 2022, 06: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

Offline MrToga

  • Full Member
  • ***
  • Posts: 142
Re: Mariadb
« Reply #9 on: June 08, 2022, 07: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)
It's fine

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Mariadb
« Reply #10 on: June 08, 2022, 08: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

Offline tacpilot

  • Newbie
  • *
  • Posts: 30
Re: Mariadb
« Reply #11 on: June 08, 2022, 09:09:45 AM »
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
Never limit your creativity by the imagination of others.

Offline tacpilot

  • Newbie
  • *
  • Posts: 30
Re: Mariadb
« Reply #12 on: June 08, 2022, 09:15:55 AM »
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
Never limit your creativity by the imagination of others.

Offline tacpilot

  • Newbie
  • *
  • Posts: 30
Re: Mariadb
« Reply #13 on: June 08, 2022, 09:24:49 AM »
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 &"
Never limit your creativity by the imagination of others.

Offline tacpilot

  • Newbie
  • *
  • Posts: 30
Re: Mariadb
« Reply #14 on: June 08, 2022, 09:25:26 AM »
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.
Never limit your creativity by the imagination of others.