Structual bashrc
This commit is contained in:
45
bash/bashrc/sources/30_mysql
Executable file
45
bash/bashrc/sources/30_mysql
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
function mysqlo () {
|
||||
if [[ -z "$1" ]]; then
|
||||
__func_head "SERVER_NAME"
|
||||
echo
|
||||
else
|
||||
PASS=$(grepmysql $1 true)
|
||||
if [[ -z "$PASS" ]]; then
|
||||
echo "Server not found in config: $1"
|
||||
return 1
|
||||
|
||||
fi
|
||||
|
||||
PS_SQL=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $4 }')
|
||||
USER=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $5 }')
|
||||
|
||||
export MYSQL_PS1="$PS_SQL> "
|
||||
|
||||
shift
|
||||
|
||||
echo $__mysql
|
||||
mysql -u $USER --password=$PASS $@
|
||||
unset PS_SQL
|
||||
fi
|
||||
}
|
||||
|
||||
function mysqls () {
|
||||
if [[ -z "$1" ]]; then
|
||||
__func_head "SERVER_NAME DATABASE_NAME SQL_FILE"
|
||||
echo
|
||||
else
|
||||
USER=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $5 }')
|
||||
PASS=$(grepmysql $1 true)
|
||||
|
||||
if [[ -z "$PASS" ]]; then
|
||||
echo "Server not found in config: $1"
|
||||
return 1
|
||||
|
||||
fi
|
||||
|
||||
mysql -u $USER --password=$PASS -D $2 < $3
|
||||
fi
|
||||
}
|
||||
|
Reference in New Issue
Block a user