Question

ERROR 1006 (HY000): Can't create database

I run mysql using mysql -u root -p

And then try to create database using : create database acp;

But then I get an error saying : ERROR 1006 (HY000): Can’t create database ‘acp’ .

I changed the permission and owner:group of /var/lib/mysql and all it’s sub directories to mysql:mysql and gave permissions 755 and even tried once with 777 but still the same error :(.

Request some one to please guide me in the right direction. Thank you!

P.S - I followed the LAMP installation tutorial on Digital Ocean and everything else has been setup properly!


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@joginayak

Glad to see that took care of it :-). If you run in to any other issues, feel free to post again and tag me in it and I’ll do my best to help you out. I don’t work for DigitalOcean, I just help here in the forums :-).

This solution don´t work for me, i have the same problem, i follow the steps of the tutorial to install phpmyadmin and mysql, but when i try to create a database with user root… same error can´t create, i try to uninstall all and nothing else, same error.

@joginayak

To create a database, you’re going to need to login as root when connecting to MySQL from the CLI, as shown in your original post. You’ll then need to do 3 things:

1). Create the Database 2). Grant Permissions on the Database 3). Flush Privileges.

Only when those are done will you be able to access the database as a non-root user.

NOTE: The single quotes DO matter, so make sure you’re using them.

So when you created the database, you ran something such as:

create database example_db;

Then to create a user, you’d run:

grant all on example_db.* to 'example_user'@'localhost' identified by 'example_password';

Then finally:

flush privileges;

You can then type in exit; to close out the connection. At this point, you should be able to login as example_user using example_pass as the password – simply replace all the example_* with your own details.

From the looks of it, #2 wasn’t done, otherwise you should be able to login without any issues (just tested this on my end on a clean droplet).