Basic advices. More to come

Sep 27, 2007 15:07 GMT  ·  By

After you installed MySQL to your machine, the installation program will create superuser accounts (one in Windows environment and two in UNIX environment) and anonymous accounts (2 in Windows and 2 in UNIX). With the superuser account, named root, you can do anything. The bad news is that it is created without any password, so you will have to "change" the password. On Windows, the account allows you to connect to the database server locally only. If you want to permit remote connections you will have to check "Enable root access from remote machines" during MySQL installation. On Unix environment, both root users permit only local connections. Connections must be made from the local host by specifying a hostname of localhost for one of the accounts, or the actual hostname or IP number for the other.

The anonymous accounts are created with empty usernames. Again, both accounts are created without any passwords, so anyone can connect to your server. But the anonymous accounts are limited accounts, so everything is OK. On Windows one anonymous account is created for connections from local host and the other one is for connections from any host and permits connection to a test database. On Unix, both anonymous accounts are for connections from local host.

If you want to assign a password for the anonymous account, I will show you how.

On Windows use the following commands: shell> mysql -u root mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('softpedia'); mysql> SET PASSWORD FOR ''@'%' = PASSWORD('softpedia');

On Unix we will use the same SET PASSWORD command: shell> mysql -u root mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('softpedia'); mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('softpedia');

Replace host name with the name of the server host.

If you don`t need the anonymous accounts, you can remove them. The method is the same for Windows and Unix. shell> mysql -u root mysql> DROP USER '';

If you want to remove the anonymous account that has the same privileges as root, you can use the following command: shell> mysql -u root mysql> DROP USER ''@'localhost';