I'd like to recommend something more secure

STEP 01 : Create a File That Puts Back the root@localhost with the password wh@t3v3r

cd /var/lib/mysql
echo "GRANT ALL PRIVILEGES ON *.* TO root@localhost " > InitFile.sql
echo "IDENTIFIED BY 'wh@t3v3r';" >> InitFile.sql
STEP 02 : Add the following to /etc/my.cnf under the [mysqld] group

STEP 03 : service mysql restart

STEP 04 : Remove init-file=/var/lib/mysql/InitFile.sql from /etc/my.cnf

STEP 05 : rm -f /var/lib/mysql/InitFile.sql

If you can connect to mysql like this:

mysql -uroot -p
Password: <type password wh@t3v3r and hit enter>

From: https://superuser.com/questions/461043/how-to-access-mysql-when-i-delete-the-root-user-on-opensuse-11