Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
a5fe0462
Commit
a5fe0462
authored
7 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Don't use mysqladmin
parent
542515be
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-utils-database
+32
-24
32 additions, 24 deletions
src/freedombone-utils-database
with
32 additions
and
24 deletions
src/freedombone-utils-database
+
32
−
24
View file @
a5fe0462
...
@@ -181,7 +181,6 @@ function install_mariadb {
...
@@ -181,7 +181,6 @@ function install_mariadb {
run_query mysql
"update mysql.user set plugin = '' where User='root@localhost'; flush privileges;"
run_query mysql
"update mysql.user set plugin = '' where User='root@localhost'; flush privileges;"
run_query mysql
"GRANT ALL PRIVILEGES ON * TO 'root@localhost'; flush privileges;"
run_query mysql
"GRANT ALL PRIVILEGES ON * TO 'root@localhost'; flush privileges;"
mysqladmin
-u
root password
"
$MARIADB_PASSWORD
"
mark_completed
$FUNCNAME
mark_completed
$FUNCNAME
}
}
...
@@ -259,27 +258,6 @@ quit" > $INSTALL_DIR/batch.sql
...
@@ -259,27 +258,6 @@ quit" > $INSTALL_DIR/batch.sql
shred
-zu
$INSTALL_DIR
/batch.sql
shred
-zu
$INSTALL_DIR
/batch.sql
}
}
function
create_database
{
app_name
=
"
$1
"
app_admin_password
=
"
$2
"
app_admin_username
=
$3
if
[
!
-d
$INSTALL_DIR
]
;
then
mkdir
$INSTALL_DIR
fi
if
[
!
$app_admin_username
]
;
then
app_admin_username
=
${
app_name
}
admin
fi
echo
"create database
${
app_name
}
;
CREATE USER '
$app_admin_username
@localhost' IDENTIFIED BY '
${
app_admin_password
}
';
update mysql.user set plugin = '' where User='
$app_admin_username
@localhost';
GRANT ALL PRIVILEGES ON
${
app_name
}
.* TO '
$app_admin_username
@localhost';
flush privileges;
quit"
>
$INSTALL_DIR
/batch.sql
chmod
600
$INSTALL_DIR
/batch.sql
mysql
-u
root
--password
=
"
$MARIADB_PASSWORD
"
<
$INSTALL_DIR
/batch.sql
shred
-zu
$INSTALL_DIR
/batch.sql
}
function
initialise_database
{
function
initialise_database
{
database_name
=
$1
database_name
=
$1
database_file
=
$2
database_file
=
$2
...
@@ -301,6 +279,28 @@ function run_query_root {
...
@@ -301,6 +279,28 @@ function run_query_root {
mysql
-e
"
$database_query
"
$database_name
mysql
-e
"
$database_query
"
$database_name
}
}
function
create_database
{
app_name
=
"
$1
"
app_admin_password
=
"
$2
"
app_admin_username
=
$3
if
[
!
-d
$INSTALL_DIR
]
;
then
mkdir
$INSTALL_DIR
fi
if
[
!
$app_admin_username
]
;
then
app_admin_username
=
${
app_name
}
admin
fi
echo
"create database
${
app_name
}
;
CREATE USER '
$app_admin_username
@localhost' IDENTIFIED BY '
${
app_admin_password
}
';
update mysql.user set plugin = '' where User='
$app_admin_username
@localhost';
GRANT ALL PRIVILEGES ON
${
app_name
}
.* TO '
$app_admin_username
@localhost';
flush privileges;
quit"
>
$INSTALL_DIR
/batch.sql
chmod
600
$INSTALL_DIR
/batch.sql
mysql
-u
root
--password
=
"
$MARIADB_PASSWORD
"
<
$INSTALL_DIR
/batch.sql
shred
-zu
$INSTALL_DIR
/batch.sql
}
function
run_query_with_output
{
function
run_query_with_output
{
database_name
=
$1
database_name
=
$1
database_query
=
$2
database_query
=
$2
...
@@ -313,11 +313,19 @@ EOF
...
@@ -313,11 +313,19 @@ EOF
}
}
function
drop_database
{
function
drop_database
{
database_name
=
$1
database_name
=
"
$1
"
get_mariadb_password
get_mariadb_password
mysqladmin
-uroot
-p
"
$MARIADB_PASSWORD
"
-f
drop
$database_name
echo
"drop database
${
app_name
}
;
flush privileges;
quit"
>
$INSTALL_DIR
/batch.sql
chmod
600
$INSTALL_DIR
/batch.sql
mysql
-u
root
--password
=
"
$MARIADB_PASSWORD
"
<
$INSTALL_DIR
/batch.sql
shred
-zu
$INSTALL_DIR
/batch.sql
}
}
function
database_reinstall
{
function
database_reinstall
{
apt-get
-yq
purge mariadb
*
apt-get
-yq
purge mariadb
*
rm
-rf
/var/lib/mysql
rm
-rf
/var/lib/mysql
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment