Answer the question
In order to leave comments, you need to log in
How to find the root user password for a MySQL database in Ubuntu?
I got one VPS server, as an inheritance, so to speak. The former owner has not been contacted. How do I find out the root user password for a MySQL database? Where is it stored on the Ubuntu 14.04 filesystem?
Answer the question
In order to leave comments, you need to log in
#!/bin/bash
mysql_password="новый_пароль"
/etc/init.d/mysql stop
echo "UPDATE mysql.user SET Password=PASSWORD('${mysql_password}') WHERE User='root';" > /tmp/mysql-set-pass
echo "FLUSH PRIVILEGES;" >> /tmp/mysql-set-pass
su -c "mysqld_safe --init-file=/tmp/mysql-set-pass &" mysql --shell=/bin/bash
sleep 5
echo "[mysql]
password = ${mysql_password}
[mysqldump]
password = ${mysql_password} " > /root/.my.cnf
/etc/init.d/mysql restart
mysql --password="" -e "SELECT 1;" 2>/dev/null && exit 1
mysql -e "SELECT 1;" 1>/dev/null || exit 1
rm /tmp/mysql-set-pass
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question