Snippet to use in your scripts to execute them only if you have root privileges.
犀利士
bash |copy code |?
1 if [ $UID -ne 0 ]; then2 echo "Superuser privileges are required to run this script."3 echo "e.g. "sudo $0""4 exit 1 fi
Snippet to use in your scripts to execute them only if you have root privileges.
犀利士
bash |copy code |?
1 if [ $UID -ne 0 ]; then2 echo "Superuser privileges are required to run this script."3 echo "e.g. "sudo $0""4 exit 1 fi
You can perform the password change with mysqladmin command
bash |copy code |?
1 mysqladmin -u root password "newpwd"2 mysqladmin -u root -h host_name password "newpwd"