Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
27c3b6e6
Commit
27c3b6e6
authored
Aug 20, 2020
by
Daniel Black
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-23494: mysql_install_db add --auth-root-password-env option
parent
cfe0f1bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
14 deletions
+24
-14
scripts/mysql_install_db.sh
scripts/mysql_install_db.sh
+16
-7
scripts/mysql_system_tables_data.sql
scripts/mysql_system_tables_data.sql
+8
-7
No files found.
scripts/mysql_install_db.sh
View file @
27c3b6e6
...
@@ -41,6 +41,7 @@ auth_root_socket_user='root'
...
@@ -41,6 +41,7 @@ auth_root_socket_user='root'
tzdir
=
tzdir
=
skip_anonymous
=
skip_anonymous
=
explicit_hostname
=
explicit_hostname
=
root_password
=
dirname0
=
`
dirname
$0
2>/dev/null
`
dirname0
=
`
dirname
$0
2>/dev/null
`
dirname0
=
`
dirname
$dirname0
2>/dev/null
`
dirname0
=
`
dirname
$dirname0
2>/dev/null
`
...
@@ -63,6 +64,11 @@ Usage: $0 [OPTIONS]
...
@@ -63,6 +64,11 @@ Usage: $0 [OPTIONS]
to 'root'.
to 'root'.
--auth-root-hostname=name
--auth-root-hostname=name
Use name as host for root user without DNS resolving it.
Use name as host for root user without DNS resolving it.
(for --auth-root-authentication-method=normal)
--auth-root-password-env
Use the
\$
MARIADB_ROOT_PASSWORD as the root user password.
(needs to be SQL escaped, for
--auth-root-authentication-method=normal)
--basedir=path The path to the MariaDB installation directory.
--basedir=path The path to the MariaDB installation directory.
--builddir=path If using --srcdir with out-of-directory builds, you
--builddir=path If using --srcdir with out-of-directory builds, you
will need to set this to the location of the build
will need to set this to the location of the build
...
@@ -181,6 +187,8 @@ parse_arguments()
...
@@ -181,6 +187,8 @@ parse_arguments()
auth_root_authentication_method
=
socket
;;
auth_root_authentication_method
=
socket
;;
--auth-root-hostname
=
*
)
--auth-root-hostname
=
*
)
explicit_hostname
=
`
parse_arg
"
$arg
"
`
;;
explicit_hostname
=
`
parse_arg
"
$arg
"
`
;;
--auth-root-password-env
)
root_password
=
$MARIADB_ROOT_PASSWORD
;;
--auth-root-authentication-method
=
*
)
--auth-root-authentication-method
=
*
)
usage
;;
usage
;;
--auth-root-socket-user
=
*
)
--auth-root-socket-user
=
*
)
...
@@ -553,16 +561,17 @@ cat_sql()
...
@@ -553,16 +561,17 @@ cat_sql()
fi
fi
case
"
$auth_root_authentication_method
"
in
case
"
$auth_root_authentication_method
"
in
normal
)
normal
)
install_params
=
"
$install_params
echo
"SET @skip_auth_root_native_password=NULL;"
SET @skip_auth_root_nopasswd=NULL;
echo
"SET @auth_root_password='
$root_password
';"
SET @auth_root_socket=NULL;"
;;
echo
"SET @auth_root_socket=NULL;"
;;
socket
)
socket
)
install_params
=
"
$install_params
echo
"SET @skip_auth_root_native_password=1;"
SET @skip_auth_root_nopasswd=1;
echo
"SET @auth_root_socket='
$auth_root_socket_user
';"
SET @auth_root_socket='
$auth_root_socket_user
';"
;;
;;
esac
esac
echo
"
$install_params
"
;
cat
"
$create_system_tables
"
"
$create_system_tables2
"
"
$fill_system_tables
"
"
$fill_help_tables
"
"
$maria_add_gis_sp
"
;
cat
"
$create_system_tables
"
"
$create_system_tables2
"
"
$fill_system_tables
"
"
$fill_help_tables
"
"
$maria_add_gis_sp
"
;
if
test
!
-z
"
$tzdir
"
if
test
!
-z
"
$tzdir
"
then
then
...
...
scripts/mysql_system_tables_data.sql
View file @
27c3b6e6
...
@@ -38,14 +38,15 @@ DROP TABLE tmp_db;
...
@@ -38,14 +38,15 @@ DROP TABLE tmp_db;
-- Fill "user" table with default users allowing root access
-- Fill "user" table with default users allowing root access
-- from local machine if "user" table didn't exist before
-- from local machine if "user" table didn't exist before
CREATE
TEMPORARY
TABLE
tmp_user_n
opassw
d
LIKE
user
;
CREATE
TEMPORARY
TABLE
tmp_user_n
ative_passwor
d
LIKE
user
;
CREATE
TEMPORARY
TABLE
tmp_user_socket
LIKE
user
;
CREATE
TEMPORARY
TABLE
tmp_user_socket
LIKE
user
;
CREATE
TEMPORARY
TABLE
tmp_user_anonymous
LIKE
user
;
CREATE
TEMPORARY
TABLE
tmp_user_anonymous
LIKE
user
;
-- Classic passwordless root account.
-- Classic passwordless root account.
INSERT
INTO
tmp_user_nopasswd
VALUES
(
'localhost'
,
'root'
,
''
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
''
,
''
,
''
,
''
,
0
,
0
,
0
,
0
,
''
,
''
,
'N'
,
'N'
,
''
,
0
);
SET
@
pass
=
IF
(
@
auth_root_password
=
''
,
''
,
PASSWORD
(
@
auth_root_password
));
REPLACE
INTO
tmp_user_nopasswd
SELECT
@
current_hostname
,
'root'
,
''
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y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account using unix socket auth.
INSERT
INTO
tmp_user_socket
VALUES
(
'localhost'
,
IFNULL
(
@
auth_root_socket
,
'root'
),
''
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
''
,
''
,
''
,
''
,
0
,
0
,
0
,
0
,
'unix_socket'
,
''
,
'N'
,
'N'
,
''
,
0
);
INSERT
INTO
tmp_user_socket
VALUES
(
'localhost'
,
IFNULL
(
@
auth_root_socket
,
'root'
),
''
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
'Y'
,
''
,
''
,
''
,
''
,
0
,
0
,
0
,
0
,
'unix_socket'
,
''
,
'N'
,
'N'
,
''
,
0
);
IF
@
auth_root_socket
is
not
null
THEN
IF
@
auth_root_socket
is
not
null
THEN
...
@@ -55,10 +56,10 @@ IF @auth_root_socket is not null THEN
...
@@ -55,10 +56,10 @@ IF @auth_root_socket is not null THEN
INSERT
INTO
tmp_user_anonymous
(
host
,
user
)
VALUES
(
'localhost'
,
''
);
INSERT
INTO
tmp_user_anonymous
(
host
,
user
)
VALUES
(
'localhost'
,
''
);
INSERT
INTO
tmp_user_anonymous
(
host
,
user
)
SELECT
@
current_hostname
,
''
FROM
dual
WHERE
@
current_hostname
!=
'localhost'
;
INSERT
INTO
tmp_user_anonymous
(
host
,
user
)
SELECT
@
current_hostname
,
''
FROM
dual
WHERE
@
current_hostname
!=
'localhost'
;
INSERT
INTO
user
SELECT
*
FROM
tmp_user_n
opasswd
WHERE
@
had_user_table
=
0
AND
@
skip_auth_root_nopassw
d
IS
NULL
;
INSERT
INTO
user
SELECT
*
FROM
tmp_user_n
ative_password
WHERE
@
had_user_table
=
0
AND
@
skip_auth_root_native_passwor
d
IS
NULL
;
INSERT
INTO
user
SELECT
*
FROM
tmp_user_socket
WHERE
@
had_user_table
=
0
AND
@
auth_root_socket
IS
NOT
NULL
;
INSERT
INTO
user
SELECT
*
FROM
tmp_user_socket
WHERE
@
had_user_table
=
0
AND
@
auth_root_socket
IS
NOT
NULL
;
INSERT
INTO
user
SELECT
*
FROM
tmp_user_anonymous
WHERE
@
had_user_table
=
0
AND
@
skip_auth_anonymous
IS
NULL
;
INSERT
INTO
user
SELECT
*
FROM
tmp_user_anonymous
WHERE
@
had_user_table
=
0
AND
@
skip_auth_anonymous
IS
NULL
;
DROP
TABLE
tmp_user_n
opassw
d
,
tmp_user_socket
,
tmp_user_anonymous
;
DROP
TABLE
tmp_user_n
ative_passwor
d
,
tmp_user_socket
,
tmp_user_anonymous
;
CREATE
TEMPORARY
TABLE
tmp_proxies_priv
LIKE
proxies_priv
;
CREATE
TEMPORARY
TABLE
tmp_proxies_priv
LIKE
proxies_priv
;
INSERT
INTO
tmp_proxies_priv
VALUES
(
'localhost'
,
'root'
,
''
,
''
,
TRUE
,
''
,
now
());
INSERT
INTO
tmp_proxies_priv
VALUES
(
'localhost'
,
'root'
,
''
,
''
,
TRUE
,
''
,
now
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment