2

I am writing the shell script to automatically install all the required packages for PHP site, I have written the script to automate the installation. I am using below script to install the mysql without prompt for password:

#!/bin/sh
LOGFILEPATH=/home/philtracker/logs/logs.log
echo "Executing Installation script">>$LOGFILEPATH
for i in apache2 php5 libapache2-mod-php5  php5-json mysql-server apache2-mod-auth-mysql     php5-mysql
    do
        sudo apt-get -y install $i
        if [ $? -ne 0 ] ; then
            echo "$i: installation failed for $i">>$LOGFILEPATH 2>&1
        else
            echo "$i: Installation successful for $i">>$LOGFILEPATH 2>&1
    fi
done

The above script installing the all packages successfully, But as I have automated the installation for MYSQL I don't have a password to login to mysql. Is there any default password set by MySQL ?

5
  • 1
    which specific version of mysql are you using? Commented May 2, 2014 at 14:52
  • 1
    on a fresh/clean install, the root account usually has no password. Commented May 2, 2014 at 14:52
  • I can do a trick using script to reset the password of root user but I want to check if there is any other alternative Commented May 2, 2014 at 14:53
  • I am using mysql 5.5.37 ubuntu version Commented May 2, 2014 at 14:54
  • If root account has no password is there any way to login ? Commented May 2, 2014 at 14:55

1 Answer 1

1

I believe it's root/root...or it's blank!

You can also directly update the password:

UPDATE
   mysql.user
SET
   Password=PASSWORD('MyNewPass')
WHERE
   User='root'; FLUSH PRIVILEGES;

http://www.thegeekstuff.com/2009/01/15-practical-usages-of-mysqladmin-command-for-administering-mysql-server/

Sign up to request clarification or add additional context in comments.

4 Comments

Yes, I can do this to reset the password, I have tried this and it works but I am thinking if I have any default password then I can skip change password. Both root/root...or blank isn't working
For running above command I need to first login in to mysql and I can't as I don't have a password to log in
blank should be default - root/toor is only other immediate suggestion...let me ask my old dba.
thanks, It works It was my mistake I was using "mysql -uroot -p" instead of using "mysql -uroot" only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.