0
votes

When I try to create a new database(m) in xampp mysql command window then I'm getting an error message

"ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'm'".

Then I created that database by using phpmyadmin but its not shown in mysql command window when I type show databases command there. Can anybody tell me how can I get rid of that error message and can successfully create new database by using mysql command window in xampp? (I'm using windows xp professional service pack-2)

-Thanks.

4
Edit: My xampp file- 'xampp-win32-1.8.1-VC9-installer',the installation process was fine and I kept all default settings,didn't change anything. - user1826381
EDIT 2: mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.00 sec) mysql> use test; Database changed mysql> use m; ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'm' - user1826381
EDIT 3: New database can be created and all operations can be done by using phpmyadmin but that database is not shown in mysql command window and can't create new database by using 'create database' command.But can use 'test' database which is default there and can create and use tables within that.Just can't create any new database there. - user1826381
(and in 'xampp\mysql\data\m' folder there just 1 file 'a.frm' is created for table 'a'.) - user1826381
EDIT 4: In mysql 'shell' its working and all databases are shown there but in 'xampp\mysql\bin\mysql.exe' those databases aren't shown there and also can't create new database. - user1826381

4 Answers

0
votes

Are you logging as a root?

Browse to the mysql.exe containing foler and try typing this in the cmd:

mysql.exe -u root --password
0
votes

Try to initiate your mysql client with a specific username and password ( if you have set one )

mysql.exe -uroot [-p]

Edit: Add this to your my.cnf [client] section to log-in without any parameter

[client]
user=root

http://dev.mysql.com/doc/refman/5.5/en/mysql-command-options.html

0
votes

RESOLVED:** Thanks to all for your kind replies. I solved that problem.

I changed the 'user' table in 'mysql' database by using phpmyadmin and set the fields to 'Y' while those were 'N' where host was 'localhost'(so localhost wasn't able to create or drop any database).Now its possible to create new database by 'xampp\mysql\bin\mysql.exe'.

AND **to get .frm(table definition), .MYD(table data) and .MYI(table indices) files for a table in mysql data folder,I SET type=MyISAM and collation=utf8_general_ci so it would be easy to copy the database to another pc or server.

0
votes

I know you've solved the problem .I had the same problem ,but the answer is simple .Answer :if you type "localhost" in your browser ,after selecting the language , you can select "phpmyadmin" .then as you said you can click on the "Databases" tab ,then from the list of databases select "mysql" and eventually you can see that the last table of this database is "user" table.if you then click on the "browse" button right in front of the name of the table which is "user". now you can see the "user" table in detail.you can see under the "host" column there are 3 "localhost" cells ,but only one of them has value of "root" in the "user" column which is the next .so if you want to connect mysql via command prompt , if you have not set password yet ,( c:\xampp\mysql\bin\mysql.exe -u root ) not ( c:\xampp\mysql\bin\mysql.exe ) or not ( c:\xampp\mysql\bin\mysql.exe -u root -p ) .