Create default ‘root’ user for MySQL

Recently, I had the issue that the MySQL ‘root’ user could not log into the data base:

shell> mysql -u root -p
Access denied for user 'root'@'localhost' (using password: YES)

The root cause was not that a wrong password was used or the user ‘root’ had no access rights. The root cause was that the user ‘root’ was not existing in the mysql.user table. In fact, the whole user table was empty. So the default ‘root’ user needs to be recreated again.

In order to log into MySQL without a user and password, MySQL needs to be restarted with the --skip-grant-tables option.

shell> service mysqld stop
shell> /usr/bin/mysqld_safe --skip-grant-tables &

Then log into MySQL

shell> mysql

The usual CREATE USER command will not work here as this command would also set default permissions, however starting MySQL without grant tables will not allow you to set permissions. So the user ‘root’ needs to manually inserted into the mysql.user table, along with all privileges.

mysql> USE user;

mysql> INSERT INTO user (Host, User, Password) VALUES ('localhost','root','MyNewPass');
Query OK, 1 rows affected (0.04 sec)

mysql> UPDATE user SET Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y' WHERE user='root';
Query OK, 1 rows affected (0.03 sec)

Newer versions of MySQL might contain more privileges so make sure that all have been updated (all ‘*_priv’ columns contain a ‘Y’).

mysql> SELECT * FROM user WHERE user='root';

Then quit the database console, kill the mysqld_safe daemon, start the standard mysql daemon and test it again.

mysql> quit;

shell> killall mysqld_safe

shell> service mysqld start

shell> mysql -u root -p

The default ‘root’ user has now been restored and access with a password should be possible again!

Tired of multiple “fake” email addresses?

Honestly, how many fake, forgotten, or abandoned email addresses have owned within your internet era? Whether for registering to a forum you only need once, selling an item on craigslist, signing up for a trial software or registering to an online dating service your wife should never find out about, we’ve all had to use our creative mind to come up with new, randomized email addresses that look more like a ciphering code than an actual word or name (bs77flat01@hotmail.com).

No need for that anymore, thanks to – you guessed right – Google!

Gmail supports sub-addressing (RFC5233) of emails. Messages can be sent to addresses in the format username+extratext@gmail.com, where extratext can be any string, and will arrive in the inbox of username@gmail.com.

Gmail also does not recognize dots as characters within a username. Instead, it will ignore all dots in a username. For instance, the account google@gmail.com receives mail sent to goo.gle@gmail.com, g.o.o.g.l.e@gmail.com, etc. This allows users to sign up for different services with different aliases and then easily filter, delete, apply a label or create a rule from all emails from those services. In addition, should users start to receive spam messages that are directed to their email address with the extra text or dots, they will know what services have leaked out their email address to others.