From 683f91a287c25ee3175013a69fb36925dd656fea Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Wed, 25 Aug 2021 09:15:24 +0200 Subject: Fix mysql_setpermission hostname logic Changes: - Don't include port in connection parameters with 'localhost' hostname More info: The hostname, if not specified or specified as '' or 'localhost', will default to a MySQL server running on the local machine using the default for the UNIX socket. To connect to a MySQL server on the local machine via TCP, you must specify the loopback IP address (127.0.0.1) as the host. Reported issue: https://bugzilla.redhat.com/show_bug.cgi?id=1976224 --- scripts/mysql_setpermission.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index 71462d28622..01b3d5e7e90 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -52,6 +52,7 @@ use strict; use vars qw($dbh $sth $hostname $opt_user $opt_password $opt_help $opt_host $opt_socket $opt_port $host $version); +my $sqlport = ""; my $sqlhost = ""; my $user = ""; @@ -84,9 +85,13 @@ if ($opt_password eq '') print "\n"; } +# Using port argument with 'localhost' will cause an error +if ($sqlhost ne "localhost") { + $sqlport = ":port=$opt_port"; +} # make the connection to MariaDB -$dbh= DBI->connect("DBI:mysql:mysql:host=$sqlhost:port=$opt_port:mysql_socket=$opt_socket",$opt_user,$opt_password, {PrintError => 0}) || +$dbh= DBI->connect("DBI:mysql:mysql:host=$sqlhost$sqlport:mysql_socket=$opt_socket",$opt_user,$opt_password, {PrintError => 0}) || die("Can't make a connection to the mysql server.\n The error: $DBI::errstr"); # the start of the program -- cgit v1.2.1 From c45aeeab38125e59c84c2d7a78e8465e0964e5b5 Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Wed, 25 Aug 2021 09:18:29 +0200 Subject: Remove FLUSH PRIVILEGES from mysql_setpermission FLUSH PRIVILEGES hasn't been needed for very many years. --- scripts/mysql_setpermission.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index 01b3d5e7e90..7c0ef575db7 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -283,7 +283,6 @@ sub addall { $sth = $dbh->do("REVOKE ALL ON $db.* FROM \'$user\'\@\'$host\'") || die $dbh->errstr; } } - $dbh->do("FLUSH PRIVILEGES") || print STDERR "Can't flush privileges\n"; print "Everything is inserted and mysql privileges have been reloaded.\n\n"; } -- cgit v1.2.1