[MDEV-23015] mariadb-setpermission seems incompatible with DBI:MariaDB Created: 2020-06-25  Updated: 2023-11-20  Resolved: 2021-04-13

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.5.4
Fix Version/s: 10.5.10

Type: Bug Priority: Minor
Reporter: Anders Karlsson Assignee: Anel Husakovic
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux CentOS 7.7


Issue Links:
Relates
relates to MDEV-23016 mariadb-setpermission Closed
relates to MDEV-26474 Fix mysql_setpermission hostname logic Closed
relates to MDEV-31611 mariadb-setpermission: Can't use stri... Closed

 Description   

When running mariadb-setpermission it fails to connect to MariaDB. On line 89 (in MariaDB 10.5.4) it tries to connect using port/host and mariadb_socket, and all three of these cannot be used together. You get the error:
Can't make a connection to the mysql server.
The error: Connection error: host or port cannot be specified together with mariadb_socket at /usr/bin/mariadb-setpermission line 89, <STDIN> line 1.



 Comments   
Comment by Elena Stepanova [ 2020-08-04 ]

It seems to be a problem specific to DBD::MariaDB. In previous versions, which use DBD::mysql, it works fine.

Comment by Elena Stepanova [ 2020-08-04 ]

Since we cannot control DBD::MariaDB, I guess it has to be worked around in the script itself.

Comment by Anel Husakovic [ 2021-03-11 ]

Hi sanja can you please review 9e5202f6f96?

$ ./scripts/mariadb-setpermission --socket=/tmp/mysql.sock
Options read from mycnf:
user=anel
password=
Password for user anel to connect to MariaDB: 
######################################################################
## Welcome to the permission setter 1.4 for MariaDB.
## made by Luuk de Boer
######################################################################
What would you like to do:
  1. Set password for an existing user.
  2. Create a database + user privilege for that database
     and host combination (user can only do SELECT)
  3. Create/append user privilege for an existing database
     and host combination (user can only do SELECT)
  4. Create/append broader user privileges for an existing
     database and host combination
     (user can do SELECT,INSERT,UPDATE,DELETE)
  5. Create/append quite extended user privileges for an
     existing database and host combination (user can do
     SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,
     LOCK TABLES,CREATE TEMPORARY TABLES)
  6. Create/append full privileges for an existing database
     and host combination (user has FULL privilege)
  7. Remove all privileges for for an existing database and
     host combination.
     (user will have all permission fields set to N)
  0. exit this program
 
Make your choice [1,2,3,4,5,6,7,0]:

or

$ ./scripts/mariadb-setpermission --host=anel --user=t --password=ttt
Options read from mycnf:
######################################################################
## Welcome to the permission setter 1.4 for MariaDB.
## made by Luuk de Boer
######################################################################
What would you like to do:
  1. Set password for an existing user.
  2. Create a database + user privilege for that database
     and host combination (user can only do SELECT)
  3. Create/append user privilege for an existing database
     and host combination (user can only do SELECT)
  4. Create/append broader user privileges for an existing
     database and host combination
     (user can do SELECT,INSERT,UPDATE,DELETE)
  5. Create/append quite extended user privileges for an
     existing database and host combination (user can do
     SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,
     LOCK TABLES,CREATE TEMPORARY TABLES)
  6. Create/append full privileges for an existing database
     and host combination (user has FULL privilege)
  7. Remove all privileges for for an existing database and
     host combination.
     (user will have all permission fields set to N)
  0. exit this program
 
Make your choice [1,2,3,4,5,6,7,0]: 1

The patch is also related to MDEV-23016.

Also there was a question on KB https://mariadb.com/kb/en/mysql_setpermission-depracated/
I agree that we should use chmod to this file, right?

Comment by Anel Husakovic [ 2021-04-07 ]

Hi sanja here is the patch for compatibility with DBD::mysql : patch
Example (used print for dsn temporary) :

DBD::MariaDB

$ ./scripts/mariadb-setpermission --socket=/tmp/mysql.sock
Options read from mycnf:
------------------------
Password for user  to connect to MariaDB: 
I used dsn: DBI:MariaDB:;mariadb_socket=/tmp/mysql.sock

Uninstall DBD::MariaDB

 sudo cpanm --uninstall DBD::MariaDB
DBD::MariaDB contains the following files:
 
  /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/MariaDB.pm
  /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/MariaDB.pod
  /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/MariaDB/INSTALL.pod
  /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/README.pod
  /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/auto/DBD/MariaDB/MariaDB.so
  /usr/local/man/man3/DBD::MariaDB.3pm
  /usr/local/man/man3/DBD::MariaDB::INSTALL.3pm
 
Are you sure you want to uninstall DBD::MariaDB? [y] y
 
Unlink: /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/MariaDB.pm
Unlink: /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/MariaDB.pod
Unlink: /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/MariaDB/INSTALL.pod
Unlink: /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBD/README.pod
Unlink: /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/auto/DBD/MariaDB/MariaDB.so
Unlink: /usr/local/man/man3/DBD::MariaDB.3pm
Unlink: /usr/local/man/man3/DBD::MariaDB::INSTALL.3pm
Unlink: /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/auto/DBD/MariaDB/.packlist
 
Successfully uninstalled DBD::MariaDB

DBD::mysql

$ ./scripts/mariadb-setpermission --socket=/tmp/mysql.sock
Options read from mycnf:
------------------------
Password for user  to connect to MariaDB: 
I used dsn: DBI:mysql:;mysql_socket=/tmp/mysql.sock

Comment by Oleksandr Byelkin [ 2021-04-13 ]

OK to push (afterall it is internal scripts)

Comment by Anel Husakovic [ 2021-04-13 ]

Pushed with 18a829012

Generated at Thu Feb 08 09:19:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.