ERROR 1044 (42000) at line 2: Access denied for user ‘root’@’%’ to database ‘db’

ERROR 1044 (42000) at line 2: Access denied for user 'root'@'%' to database 'irm'

When I create the ‘root’@’%’ user via mysql, I forgot the grant option:

grant all on *.* to 'root'@'%' identified by 'password' with grant option;

3 thoughts on “ERROR 1044 (42000) at line 2: Access denied for user ‘root’@’%’ to database ‘db’

  1. Dylan

    I had the same issue, was caused by a ‘create database’ in a dump I did. I removed the command and the subsequent ‘use’ statement and it worked.

    Commands:
    mysqldump database_to_backup –quick -c -B -F > db_dump

    grep -v database_to_backup db_dump > db_dump_minus_create

    mysql -u db_user -ppassword -D new_database < db_dump_minus_create

    Yes this can be done in less lines but i was moving machine, I had to gzip/ftp/gunzip before I realized I had the issue.

  2. Henny Savenije

    I have tried the above solution.

    root@cpanel [/home/hennysav/public_html]# /etc/rc.d/init.d/mysqld stop
    -bash: /etc/rc.d/init.d/mysqld: No such file or directory
    root@cpanel [/home/hennysav/public_html]# service mysql stop
    Shutting down MySQL…………. [ OK ]
    root@cpanel [/home/hennysav/public_html]# service mysql start –skip-grant-tables –user=root options
    Starting MySQL [ OK ]
    root@cpanel [/home/hennysav/public_html]# mysql -h localhost -u hennysav_gebruik -p -B <the_backup.txt
    Enter password:

    root@cpanel [/home/hennysav/public_html]#
    root@cpanel [/home/hennysav/public_html]#

    So it looks as if the backup was entered in the database, but browsing through the database nothing is there. I even tried to connect in MySQL to the database and read in the text file

    Also something seems to happen

    …………..
    Query OK, 3486 rows affected (0.40 sec)
    Records: 3486 Duplicates: 0 Warnings: 0

    Query OK, 3835 rows affected (0.35 sec)
    Records: 3835 Duplicates: 0 Warnings: 0

    Query OK, 3894 rows affected (0.33 sec)
    Records: 3894 Duplicates: 0 Warnings: 0
    …………..

    (this just a part of the result. Publishing everything here would make the message too long)

    but I have no idea in which database or where these data goes.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.