0

I need to learn what sql is. But am too scared of creating a database as root. This is my current "progress":

$pacman -Syu mariadb  # succeeds
$mysql_install_db --basedir=~/.sql/install --datadir=~/.sql/dat
FATAL ERROR: Could not find my_print_defaults

Now what? Give me an sql 101 tutorial with whichever implementation is popular with Arch.


@fra-san Of course

@terdon I was following this Everyone says Maria is the best, I just don't know how to handle her.

@JeffSchaller I want to have a non-privileged database I can play with.

3
  • 1
    if you're on Arch, you have access to one of the best collections of documentation in the *nix world, take advantage of it! Have you looked at wiki.archlinux.org/index.php/MariaDB? I see you're running mysql_install_db and not mariadb-install-db as recommended there. Commented Jun 17, 2020 at 17:23
  • Requests for tutorials are off-topic; learning SQL seems like a bit much for a single question as well. Is your question simply about creating a non-root database? Should we tackle the "my_print_defaults" fatal error here? Commented Jun 17, 2020 at 17:53
  • @Vorac, the intention of these clarifying comments are for you to update your question to answer them in a self-contained way -- so that the comments can be removed. Please further edit your question to spell out the question you're referring to and the corresponding answer(s). That way, when the comments go away, the post still makes sense. Thank you! Commented Jun 18, 2020 at 18:00

1 Answer 1

1

When initializing MariaDB's data directories on Arch Linux you only need to set the --basedir option if you installed MariaDB in a custom location. It's not needed in your case, since you installed the official mariadb package using pacman.
(To find out more you may directly inspect the /usr/bin/mysql_install_db shell script: --basedirs's argument (which is auto-detected when it's not set) is used as a prefix in paths of executable files and libraries, not to designate a location for user's data).

Running

mkdir ~/.sql
mysql_install_db --datadir="/home/$(id -u -n)/.sql/dat"

as your regular user should be enough. This implies that you are then going to also run mysqld (the database server process) as your user. For instance:

mkdir /run/user/$(id -u)/mariadbtest/
mysqld --socket=/run/user/$(id -u)/mariadbtest/mysql.socket \
       --datadir="/home/$(id -u -n)/.sql/dat"

And you should then be able to connect using:

mysql --socket=/run/user/$(id -u)/mariadbtest/mysql.socket

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.