No reinventes la rueda, palurdo
mysql -u root -p GRANT ALL ON *.* TO root@'%' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;