User avatar
RDK
Posts: 261
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Installing MariaDB on Stretch

Sat Apr 06, 2019 3:12 pm

I set out to install MySQL but I gather that Raspbian is now working with MariaDB and that it is fully compatible with MySQL. Ok no problem as I'm a new user to either.

I installed like this:

Code: Select all

$ sudo apt-get install mariadb-server
$ sudo mysql -u me -p
	Enter password:
	ERROR 1698 (28000): Access denied for user 'me'@'localhost'
$ sudo mysql -u root -p            
	Enter password:
  ====> should I now assume that it will be running with root privileges? <===
	Welcome to the MariaDB monitor.  Commands end with ; or \g.
	Your MariaDB connection id is 6
	Server version: 10.1.37-MariaDB-0+deb9u1 Raspbian 9.0
	Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
	Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Several web references said that during the install I would be prompted for the password for the MariaDB root user. That did not happen.

Is there a good tutorial (MariaDB for Dummies) on how to get started? ie. create the database on an external device? how do I get access without using root? What about other users and program access? Etc....RDK.

stockton
Posts: 109
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa

Re: Installing MariaDB on Stretch

Sat Apr 06, 2019 3:36 pm

I seem to remember that MariaDB, which I installed ages ago, on initial install does not have a password for root.

User avatar
RDK
Posts: 261
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Installing MariaDB on Stretch

Sat Apr 06, 2019 3:49 pm

OK, but when I ran the

Code: Select all

sudo mysql -u root -p
command I tried to use a different user id and PW but that was rejected. When I ran it again with root as the user and used the REAL root password for my box, it worked. I'm not real happy to have it require the REAL root id and password....RDK

User avatar
rpdom
Posts: 15209
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Installing MariaDB on Stretch

Sat Apr 06, 2019 4:52 pm

The default for MariaDB on Debian is to use just sudo mysql -u root (no -p option).

fbe
Posts: 518
Joined: Thu Aug 17, 2017 9:08 pm

Re: Installing MariaDB on Stretch

Sat Apr 06, 2019 9:37 pm

You can even omit the "-u root" option.

Code: Select all

sudo mysql
should login you as root@localhost to your MariaDB server on your Raspberry Pi.
RDK wrote:
Sat Apr 06, 2019 3:12 pm
Several web references said that during the install I would be prompted for the password for the MariaDB root user. That did not happen.

Is there a good tutorial (MariaDB for Dummies) on how to get started? ie. create the database on an external device? how do I get access without using root? What about other users and program access? Etc....RDK.
On Debian/Raspbian systems the user root@localhost is not authenticated by password but by the operating system. You must be root in Linux to login as root to MariaDB. You shouldn't touch the root@localhost authentication unless you know what you are doing. There are "MariaDB from Dummies" tutorials around, that show you, how to setup native password authentication for the root user without explaining, what will break if you do that.

Login as root (sudo mysql) and create a second database superuser with all privileges:

Code: Select all

create user 'admin'@'localhost' identified by 'secret';
grant all privileges on *.* to 'admin'@'localhost' with grant option;
If you are lazy, you could create the user and grant all privileges with one command:

Code: Select all

grant all privileges on *.* to 'admin'@'localhost' identified by 'secret' with grant option;
secret should be replaced with a good password. Then type "exit;" to leave the mysql client program.

If a tutorial advises to login as root to MariaDB/MySQL, login as admin.

Code: Select all

mysql -u admin -p
If you login as admin to MariaDB you can destroy only your database. If you use sudo to login as root to MariaDB, the mysql client has the privilege to destroy the whole Raspbian system...

Other tutorials are available at https://mariadb.com/kb/en/ (select "Training & Tutorials").

User avatar
RDK
Posts: 261
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Installing MariaDB on Stretch

Sun Apr 07, 2019 5:30 am

Thanks. I'll re-read this the study your links. RDK

User avatar
John_Spikowski
Posts: 1392
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Installing MariaDB on Stretch

Sun Apr 07, 2019 5:52 am

The new root permission requirement gave me fits with phpmyadmin until I realized the change and created a new user with full permissions.

User avatar
RDK
Posts: 261
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Installing MariaDB on Stretch

Sun Apr 07, 2019 8:51 am

OK, correct me if I'm wrong:
1. to create the non-root user with root powers (ie "admin") I have to use the sudo mysql command?
and then

Code: Select all

create user 'admin'@'localhost' identified by 'a good pw';
grant all privileges on *.* to 'admin'@'localhost' with grant option;
2. After that I use the mysql -u admin -p command and specify my above pw to create any new users or other MySQL commands?

After the above, I should never need to use the sudo mysql command again? And, any users I create for MariaDB using the command in 2. above will have no relationship for Pi OS users, even if they have the same user name???

Now I need to read/search for ways to have my MariaDB file on a USB memory stick and not on the OS SD card, but that will probably be another question/topic....RDK

Return to “Beginners”