All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Need some help changing MySQL root password from command line
I'm trying to write a script for changing MySQL root password from command line. I'm following the official documentation from here:
http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_init-file
This is the script I wrote:
shopt -s xpg_echo
echo "stopping running MySQL server\n"
invoke-rc.d mysql stop
echo "creating init file in a mysqld readable location\n"
cat > /tmp/mysql-init <<END
UPDATE mysql.user SET Password=PASSWORD('x123') WHERE User='root';
FLUSH PRIVILEGES;
END
echo "running mysqld_safe with init-file in the background\n"
mysqld_safe --init-file=/tmp/mysql-init &
echo "stopping mysql\n"
invoke-rc.d mysql stop
echo "deleting the init file\n"
rm /tmp/mysql-init
echo "starting mysql\n"
invoke-rc.d mysql start
My problem is that I have to start mysqld_safe with & and stop it later. My problem is that I don't know when it's initialized. Do you know any trick for checking that? Now the script goes faster then how mysql initializes. I'm thinking about a for loop what check at every 100 ms if mysql has initialized, and only then stops it. How do you do this?
Comments
Use mysqladmin to reset root password
you need to know the old one for this
Why don't you start up the mysql_safe first, then execute the SQL statement?
query.sql
use mysql; UPDATE mysql.user SET Password=PASSWORD('x123') WHERE User='root'; FLUSH PRIVILEGES; END
then execute this
mysql < query.sql
After which, check for exit code
[svr1:/root]# echo $? 0
Hope this helps
It requires root password, like the other solution. I think I'll just settle down for a sleep 5 after mysqld_safe, it works reliably.