Ошибка sql 1044

I have strange error. I am logged in local Mysql as root via command line. After creating database:

create database some_db;

Then giving privileges to some user:

grant all privileges on some_db.* to some_user@'localhost' identified by 'password';

This is giving error:

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'some_db'

The permissions for the root(show grants;) shows:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*8919C53DC7A4DFBF3F8584382E96463583EB7FDA' 

I am also making sure i am logged in as root:

select current_user();

And this confirms that i am logged in as ‘root’@’localhost’

I have created database and assigned user multiple times and never had an issue. Why i am unable assign user to the database created by root while logged in as root?

p.s. from other posts, i am thinking the issue may be caused due to some strange users

select host, user from mysql.user;

Some users that i have not added but does show up:

 MY_COMPuTER_name.local |       ''
 MY_COMPuTER_name.local |     root

I tried to delete these users

drop user 'root'@'MY_COMPuTER_name.local';
drop user ''@'MY_COMPuTER_name.local';

However, while it states query run successful, the users are not dropped even after flush privileges. Why i am unable delete users? Any help is much appricated

I tried a lot to import the sql script to create database and tables through phpmyadmin in the new site I hosted. But i’m getting the error,

1044 — Access denied for user ‘user’@’localhost’ to database ‘db’

I tried to create a sample db directly : create database sampled; I’m getting the same access denied error.

I’m not able to grant privileges to the user also, i’m getting the same access denied error.

Following is the output of show grants command,

show grants;
GRANT USAGE ON . TO 'someuser'@'localhost' IDENTIFIED BY PASSWORD 'somepw' 

GRANT ALL PRIVILEGES ON someuser\_%.* TO 'someuser'@'localhost' 

Any help would be appreciated. thank you.

Phil's user avatar

Phil

158k23 gold badges242 silver badges245 bronze badges

asked Jan 30, 2014 at 4:24

user3141777's user avatar

1

If you are using Godaddy then don’t directly go to phpMyAdmin and run the sql command.

You have to go to MySQL® Databases section and create a database there.
Then create a user and give it the permission to access the database you just created.
Now you can go to phpMyAdmin and write your SQL commands.

Hope this helps

answered Dec 16, 2015 at 19:01

5511002233's user avatar

55110022335511002233

5038 silver badges19 bronze badges

This error can be avoided in the beginning when creating the user account. Following commands must be used to create user account having all the PRIVILEDGES.

CREATE USER 'demouser'@'localhost' IDENTIFIED WITH mysql_native_password BY '***';

GRANT ALL PRIVILEGES ON *.* TO 'demouser'@'localhost' WITH GRANT OPTION;

ALTER USER 'demouser'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;

CREATE DATABASE IF NOT EXISTS 'demouser';

GRANT ALL PRIVILEGES ON `demouser`.* TO 'demouser'@'localhost';

answered Aug 3, 2022 at 17:22

HIMANSHU SHEKHAR's user avatar

1

It is clear that the user someuser do not have proper privilege over the database db. You need to grant privileges for the user over the database to correct this issue.

If you do bot have administrative rights contact your admin for granting privileges to someuser on that db

answered Jan 30, 2014 at 4:28

Abdul Manaf's user avatar

Abdul ManafAbdul Manaf

4,7683 gold badges27 silver badges34 bronze badges

For me the problem is I’m not having permissions to Create new Databasename or even Modify the name of the Database. You can contact your admin to avail privileges or if you want to quickly import the .sql file… then you can open the .sql file with text editor and find the following line:

CREATE DATABASE IF NOT EXISTS `enter the existing db name` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `enter the existing db name`;

After that try to import the .sql file…now you can successfully import all the tables!

answered May 7, 2018 at 13:29

BharathRao's user avatar

BharathRaoBharathRao

1,8561 gold badge18 silver badges28 bronze badges

I had the same problem i solve it buy change the GRANTEE and made the user he can do all the operation in PhpMyAdmin ,follow the steps :

  1. Enter to mysql in root permission but :

    sudo mysql
    Enter the password, and type this :

    SELECT * FROM information_schema.user_privileges;
    And see the user in IS_GRANTABLE is he yes or no.
    If he yes then see the PRIVILEGE_TYPE what it might it be just tow operation if it’s true add the last operations.
    and see this link to change IS_GRANTABLE from no to yes.
    I wish this could help you.

answered Mar 7, 2020 at 11:28

Mahmoud Abbas's user avatar

Must Ensure that your User_Name, Password and Database name are correct.
If you are Deal with database ‘sampled’ then type ‘sampled’ in query instead of ‘db’ also must ensure that you don’t have to use quota(‘) in Statement.

Your Common Sense's user avatar

answered Mar 29, 2017 at 2:49

Kuldeep Makwana's user avatar

you have not exported database from localhost or from web server correctly follow these steps go to localhost database click export tab than select ‘Custom — display all possible options ‘check box few options will open in section ‘output’ change compression none to zipped and now click go button at bottom it will properly export your database you can now import to hosting or anywhere you want with no errors

answered Mar 31, 2016 at 22:51

Aziz's user avatar

I started getting this error message for no reason at all. Solved by using MySQL and the Server menu option; Selected my bitnami_wordpress schema; selected the bn_wordpress user; then picked the Administrative Roles tab and granted access to this user. I had to do this to all of the users that the access was removed from.

Andrew's user avatar

Andrew

1,7451 gold badge21 silver badges29 bronze badges

answered Mar 4, 2021 at 16:02

Bud's user avatar

This page will assist you with troubleshooting a MySQL – 1044 “Access Denied” Error Message.

Troubleshooting the MySQL 1044 “Access Denied” Error

When you import a database using phpMyAdmin, generally you are importing a text file with a .sql extension.

Here is a section of code that may be in a .sql database backup. In this example, the database we are trying to import is named Employees.

-- phpMyAdmin SQL Dump -- version 2.11.9.5 -- https://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Apr 02, 2010 at 08:01 AM -- Server version: 5.0.81 -- PHP Version: 5.2.6   
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";   
CREATE DATABASE employees;   
-- --------------------------------------------------------   -- -- Table structure for table `employee_list` --   
CREATE TABLE 
IF NOT EXISTS `employee_list` ( `first_name` text NOT NULL, `last_name` text NOT NULL ) 
ENGINE=MyISAM 
DEFAULT CHARSET=latin1; 

When using phpMyAdmin to attempt to import such a file, you will receive an error message similar to:

 Error
 
SQL query:
  
 CREATE DATABASE employees;
  
 MySQL said: Documentation
 #1044 - Access denied for user 'training'@'localhost' to database 'employees'   

In this scenario, my cPanel username is Training. Because of cPanel’s database naming conventions, all database names must begin with the cPanel username followed by an “_”. I cannot create a database named Employees, however I can create a database named Training_employees.

The reason this import failed is because of the following line in the .sql file:

CREATE DATABASE employees

Again, I cannot create a database named employees, however I can create a database named Training_employees. If I change the line that says: CREATE DATABASE so that it creates: training_employees instead of employees it will again fail with the following message:  

 Error
  
 SQL query:
  
 CREATE DATABASE training_employees;
  
 MySQL said: Documentation
 #1044 - Access denied for user 'training'@'localhost' to database 'training_employees' 

When using cPanel, databases must be created within the cPanel itself. To fix the issue, you will need to:

  1. Create the: training_employees database within cPanel
  2. Comment out the: CREATE DATABASE command in my .sql file. To do this, simply change: CREATE DATABASE employees; to — CREATE DATABASE employees; You are simply adding dash dash space to the front of the line to comment it out so that it will not be executed.
  3. Log into phpMyAdmin, access the training_employees database, and then import as normal.

For Web Hosting packages

In the IONOS web hosting packages, the use of the MySQL commands CREATE DATABASE %DatabaseName% and USE %DatabaseName% are blocked for you for administrative reasons. Imports of SQL files that contain these commands fail with error 1044 — Access denied. To import a database nevertheless, for example to change the MySQL version, follow the steps below.

  • Make a backup copy of the SQL file you want to import.
  • Open the SQL file with a text editor, such as Notepad++.
  • Search for strings that are CREATE DATABASE %Database name% or USE %Database name%. %DatabaseName% is a placeholder for the actual database name in your SQL file.
  • Delete these commands. Be careful not to inadvertently remove other statements.
  • Save your changes.

How to import the cleaned SQL file into a database is described in the article Restoring a MySQL Database with phpMyAdmin.

Example

The following extract from an SQL file contains the CREATE DATABASE command in line 11 and the USE command in line 12. Since there are no other commands in either line, you can delete these lines completely.

-- phpMyAdmin SQL Dump
-- version 2.6.4-pl3
-- http://www.phpmyadmin.net
--
-- Host: db123456789.hosting-data.io
-- Creation Date: 01. Januar 2013 um 12:00
-- Server Version: 5.3.3-7+squeeze14
--
-- Database `db123456789`
--
CREATE DATABASE `db123456789` DEFAULT CHARACTER SET latin1 COLLATE lating1_english2_ci;
USE db123456789;

Fixing Error #1046 — No Database Selected

If you encounter the message Error #1046 — No database selected in phpMyAdmin instead of Error #1044, simply click on the database name on the left side in phpMyAdmin. Your database is now selected, and the database name will then also be displayed in the upper-right corner by the server name. Now you can repeat the import process.


This page will assist you with troubleshooting a MySQL — 1044 «Access Denied» Error Message.  A MySQL denial error sometimes occurs when a database is imported through phpmyadmin.

Note: If you are using cPanel, databases must be created using either the phpMyAdmin or the MySQL Database option.

1044 Access Denied Error Resolution

When you import a database using phpMyAdmin, normally you do so by importing a text file with a .sql extension. Here is a section of code that may be in a .sql database backup. In this example, the database we are trying to import is named employees.

— phpMyAdmin SQL Dump
— version 2.11.9.5
— http://www.phpmyadmin.net

— Host: localhost
— Generation Time: Apr 02, 2010 at 08:01 AM
— Server version: 5.0.81
— PHP Version: 5.2.6

SET SQL_MODE=»NO_AUTO_VALUE_ON_ZERO»;

CREATE DATABASE employees;
— ———————————————————

— Table structure for table `employee_list`

CREATE TABLE IF NOT EXISTS `employee_list` (
`first_name` text NOT NULL,
`last_name` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

When using phpMyAdmin to attempt to import such a file, you will receive an error message similar to:

Error

SQL query:

CREATE DATABASE employees;

MySQL said: Documentation
#1044 — Access denied for user ‘training’@’localhost’ to database ’employees’

In this scenario, the cPanel username is «training.» Because of cPanel’s database naming conventions, all database names must begin with the cPanel username followed by an _.  Using this format you can only creat a database named training_employees.

The reason this import failed is because of the following line in the .sql file (show above)

CREATE DATABASE employees;

Again, you cannot create a database named employees, however I can create a database named training_employees.

If I change the line that says: CREATE DATABASE so that it creates: training_employees instead of employees it will again fail with the following message:

Error

SQL query:

CREATE DATABASE training_employees;

MySQL said: Documentation
#1044 — Access denied for user ‘training’@’localhost’ to database ‘training_employees’

When using cPanel, databases must be created within the cPanel itself.

Here are the steps to correct this issue:

1. Create the training_employees database within cPanel
2. Comment out the CREATE DATABASE command in my .sql file

To do this, simply change:

CREATE DATABASE employees;
to
— CREATE DATABASE employees;

You are simply adding dash dash space to the front of the line to comment it out so that it will not be executed.

3. Log into phpMyAdmin, access the training_employees database, and then import as normal.

Понравилась статья? Поделить с друзьями:
  • Ошибка sql 1024
  • Ошибка stop c0000135 windows 7
  • Ошибка sql 10060
  • Ошибка smtp невозможно подключиться к smtp серверу
  • Ошибка p3282 мерседес