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