-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsql
More file actions
executable file
·44 lines (38 loc) · 812 Bytes
/
msql
File metadata and controls
executable file
·44 lines (38 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
default_user=asinbow.wang
default_pwd=asinbow.wang
default_database=asinbow
if [[ $# = 0 ]]; then
host="localhost"
user=$default_user
psw=$default_pwd
else
if [[ $1 == *@* ]]; then
args=$1
args=(${args//@/ })
user=${args[0]}
host=${args[1]}
echo $user
echo $host
else
user=$default_user
host=$1
fi
if [[ $# = 2 ]]; then
psw=$2
else
if [[ $user = $default_user ]]; then
psw=$default_pwd
elif [[ $user = "root" ]]; then
psw="shuobaotang"
fi
fi
fi
if [[ $host =~ ^[0-9]+$ ]]; then
host="192.168.0."$host
else
host=$host
fi
cmd="mysql -h$host -u$user -p$psw $default_database"
echo $cmd
mysql -h$host -u$user -p$psw $default_database