-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.mysql
29 lines (27 loc) · 1.09 KB
/
functions.mysql
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
mysql_local_port() {
echo "3306"
}
mysql_local_user() {
if [ -f /etc/mysql/debian.cnf ] && [ -f /var/run/mysqld/mysqld.pid ]; then
grep ^user /etc/mysql/debian.cnf |tail -n1 |sed s/\ //g |cut -d= -f2
elif [ -f /etc/mysql/debian.cnf ] && [ "`ls /var/lib/mysql/*.pid`" != "" ]; then
grep ^user /etc/mysql/debian.cnf |tail -n1 |sed s/\ //g |cut -d= -f2
elif [ -f /usr/local/directadmin/conf/mysql.conf ]; then
grep user= /usr/local/directadmin/conf/mysql.conf |tail -n1 |cut -d= -f2
elif [ -f /root/.my.cnf ]; then
grep user= /root/.my.cnf |tail -n1 |cut -d= -f2 |tr -d '"'
elif [ -f /root/.digitalocean_password ]; then
echo root
fi
}
mysql_local_password() {
if [ -f /etc/mysql/debian.cnf ]; then
grep ^password /etc/mysql/debian.cnf |tail -n1 |sed s/\ //g |cut -d= -f2
elif [ -f /usr/local/directadmin/conf/mysql.conf ]; then
grep passwd= /usr/local/directadmin/conf/mysql.conf |tail -n1 |cut -d= -f2
elif [ -f /root/.my.cnf ]; then
grep password= /root/.my.cnf |tail -n1 |cut -d= -f2 |tr -d '"'
elif [ -f /root/.digitalocean_password ]; then
cat /root/.digitalocean_password
fi
}