1

I have a mysql server (5.5.44) running on my local Ubuntu 14 machine. I can start the interactive shell via

$ mysql

When I ask to see all the databases, there is only one

mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+

If I try to make a new database I get an error

mysql> CREATE DATABASE purchases;
ERROR 1044 (42000): Access denied for user 'danielsank'@'localhost' to database 'purchases'

I am puzzled by how to resolve this problem. I'm used to mysql servers always having a database called mysql containing user access data: passwords, allowed hosts, etc. My server installation doesn't seem to have this.

How do I give myself permission to create new tables, given that there is no mysql database in the server?

asked Aug 19, 2015 at 6:09

1 Answer 1

1

The problem here is that I am invoking mysql as user danielsank, but that user does not have privileges to make new tables, nor to see the mysql database!

The issue becomes clear by invoking mysql as root

$ mysql -u root
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+

Now we can see the mysql database, and we can check it for user information

mysql> USE DATABASE mysql;
mysql> SELECT User, Host, Password FROM user;
+------------------+-------------------------+-----------------------------+
| User | Host | Password |
+------------------+-------------------------+-----------------------------+
| root | localhost | |
| root | <my machine name> | |
| root | 127.0.0.1 | |
| root | ::1 | |
| debian-sys-maint | localhost | *<a really long string> |
| danielsank | localhost | |
+------------------+-------------------------+-----------------------------+

We can create the new database

mysql> CREATE DATABASE purchases;

and grant permissions to danielsank

mysql> GRANT ALL PRIVILEGES ON purchases . * TO 'danielsank'@'localhost';
answered Aug 19, 2015 at 6:09
1
  • 1
    Although this mistake addressed by this answer is fairly elementary, I posted a question-answer because elsewhere on the internet people are advocating "fixing" this problem by nuking all of the permissions and starting over. Commented Aug 19, 2015 at 6:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.