Ask the Expert

"Create" not recognized as command

I set up MySQL on my machine, but when I type show databases, I could only get database test. I could not find database mysql, and if I countinue to use create database and create table or show table, it always says: "create" is not recognized as internal or external commands. Whats wrong with my MySQL?

    Requires Free Membership to View

Let me make an educated guess as to what is happening:

When MySQL is first installed, the passwords for the 'root' and 'anonymous' users are blank by default. When you attempt to connect to the server and do not specify a username, you are logged in as the anonymous user, and the anonymous user cannot see any database but the 'test' database. This would explain why you cannot see the 'mysql' database in the results of a SHOW DATABASES statement.

My first piece of advice is to secure your default user accounts. I personally recommend removing the anonymous account completely and assigning a password for the root account.

shell> mysql -u root mysql

mysql> DELETE FROM user WHERE User = '';

mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
   ->     WHERE User = 'root';

mysql> FLUSH PRIVILEGES;
These steps will remove the anonymous account and set the password for the root user. First we login as the 'root' user and specify that we will be using the 'mysql' database (note the -u root clause), we then issue a DELETE statement that will remove the anonymous account (which has a blank username). Next we issue an UPDATE statement to set the password for the 'root' user and finally issue a FLUSH PRIVILEGES statement. The changes you make are stored immediately into the 'user' privileges table, but do not take effect on the server until the server re-reads the privileges table, thus the FLUSH PRIVILEGES statement is used to instruct the server to re-read the privileges table.

After this you can connect to the MySQL server as follows:

shell> mysql -u root -p
The client will prompt you for the root password after which you will be successfully connected as the root user. After connected as the root user you should be able to see the 'mysql' database when you issue a SHOW DATABASES statement.

This was first published in November 2004

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: