source: npl/commonservers/mysql_conf/root/sbin/syn3-mysqlfix @ 0105685

gcc484ntopperl-5.22
Last change on this file since 0105685 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/bin/bash
2
3echo "* Resetting mysql root password..."
4
5svcstop /service/mysql || exit 1
6
7PASSWD=`cat /proc/sys/kernel/random/uuid` || exit 1
8echo "$PASSWD" > /etc/my.passwd
9#make sure those permissions are safe:
10chown root /etc/my.passwd
11chmod 700 /etc/my.passwd
12
13#also create mysql option file
14echo "
15### automaticly created by syn3-mysqlfix
16[client]
17host=localhost
18user=root
19password=$PASSWD" > /root/.my.cnf
20chmod 700 /root/.my.cnf
21
22#start mysql with the ini file:
23echo "GRANT ALL ON *.* TO 'root'@'localhost' identified by '$PASSWD' WITH GRANT OPTION;" > /etc/my.init
24
25svcstart /service/mysql
26#dont exit, always delete ini file!
27sleep 1
28rm /etc/my.init
29
30#secure database by deleting anoynmous logins and passwordless logins:
31mysql --execute="DELETE FROM mysql.user WHERE User='';" mysql &>/dev/null
32mysql --execute="DELETE FROM mysql.user WHERE Password='';" mysql &>/dev/null
33mysql --execute="flush privileges;" mysql &>/dev/null
34
35svcreset /service/mysql || exit 1
36
37echo "Mysql rootpassword resetted, stored in /etc/my.passwd and created option file for root. "
38
39exit 0
40
41
Note: See TracBrowser for help on using the repository browser.