Manage Learn to apply best practices and optimize your operations.

"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?

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';

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.

Dig Deeper on Linux servers

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.