Ошибка select command denied to user

I’m having troubles with a certain query on one of my servers. On all other places I’ve tested it it works completely fine but on the server i want to use it it isn’t working.

It’s about the following SQL:

SELECT facturen.id            AS fid, 
       projecten.id           AS pid, 
       titel, 
       facturen.totaal_bedrag AS totaal, 
       betaald, 
       datum 
FROM   facturen, 
       projecten 
WHERE  facturen.project_id = projecten.id 
       AND projecten.eigenaar = '1' 
ORDER  BY datum DESC 

This is the error code I get from it:

SELECT command denied to user 'marco'@'localhost' for table 'projecten'

The tables:
facturen:

CREATE TABLE IF NOT EXISTS `facturen` (
  `id` int(11) NOT NULL auto_increment,
  `project_id` int(11) NOT NULL,
  `datum` int(11) NOT NULL,
  `lever_datum` int(11) NOT NULL,
  `totaal_bedrag` decimal(9,2) NOT NULL,
  `btw` decimal(9,2) NOT NULL,
  `bedrijf` varchar(40) NOT NULL,
  `contactpersoon` varchar(60) NOT NULL,
  `adres` varchar(60) NOT NULL,
  `postcode` varchar(7) NOT NULL,
  `plaats` varchar(30) NOT NULL,
  `betaald` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=201200006 ;

projecten:

CREATE TABLE IF NOT EXISTS `projecten` (
  `id` int(11) NOT NULL auto_increment,
  `titel` varchar(80) NOT NULL,
  `eigenaar` int(11) NOT NULL,
  `creatie_datum` int(11) NOT NULL,
  `eind_datum` int(11) NOT NULL,
  `totaal_bedrag` decimal(9,2) NOT NULL,
  `btw` decimal(9,2) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=201200004 ;

The strange part is that every other query on both the ‘projecten’ table and the ‘facturen’ table works completely fine, also this query works fine on two other servers of mine.

Disclaimer

  • Backup first.
  • Check your query sentence before executing.
  • Make sure you’ve added a WHERE (filter) clause before updating.

In case you have root access or enough privileges, you can do the following directly:

Log into your MySQL as root,

$ mysql -u root -p

Show databases;

mysql>SHOW DATABASES;

Select MySQL database, which is where all privileges info is located

mysql>USE mysql;

Show tables.

mysql>SHOW TABLES;

The table concerning privileges for your case is ‘db’, so let’s see what columns it has:

mysql>DESC db;

In order to list the users’ privileges, type the following command, for example:

mysql>SELECT user, host, db, Select_priv, Insert_priv, Update_priv, Delete_priv FROM db ORDER BY user, db;

If you can’t find that user or if you see that that user has a ‘N’ in the Select_priv column, then you have to either INSERT or UPDATE accordingly:

INSERT:

INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv) VALUES ('localhost','DBname','UserName','Y' ,'N','N','N');

UPDATE:

UPDATE db SET Select_priv = 'Y' WHERE User = 'UserName' AND Db = 'DBname' AND Host='localhost';

Finally, type the following command:

mysql>FLUSH PRIVILEGES;

Ciao.

DevilStar wrote:
А вы, как создатель панели, не можете сказать, как создаются пользователи из панели? Со всеми необходимыми правами или нет?

Пользователи имеют доступ к тем таблицам, которые они сами и сделали, если под рутом (читать: вручную), не сделано другое. Ошибка на скрине однозначно говорит о том, что у пользователя нет доступа к таблице.

Вместо уточнения вы сейчас отвечаете вопросом на вопрос. Еще раз:
— как создавалась таблица? кем? при установке или добавлена через панель? (судя по названию предполагаю, что добавлялась она позднее, руками и под рутом; впрочем есть вероятность, что phpmyadmin для debian 8 все-таки изменил пакет и доставляет с собой базу)
— пользователь под которым редактируете таблицу — рут mysql или не рут? (подозреваю что нет)
— какие у него права на эту таблицу? (скорее всего никаких)

Давайте определимся. Я не создатель панели, а скромный энтузиаст, который тратит свое время, пытаясь сделать жизнь других чуть лучше. Не хотите помощи или готовы разбираться сами, ради бога. Однако раз написали, давайте разбираться, но для этого не всегда достаточно предоставленной информации — как-то нужно же попытаться воспроизвести ошибку. Вы должны понимать, что наколбасить на сервере можно столько, что догадаться о порядке действий будет непросто.

I’m having troubles with a certain query on one of my servers. On all other places I’ve tested it it works completely fine but on the server i want to use it it isn’t working.

It’s about the following SQL:

SELECT facturen.id            AS fid, 
       projecten.id           AS pid, 
       titel, 
       facturen.totaal_bedrag AS totaal, 
       betaald, 
       datum 
FROM   facturen, 
       projecten 
WHERE  facturen.project_id = projecten.id 
       AND projecten.eigenaar = '1' 
ORDER  BY datum DESC 

This is the error code I get from it:

SELECT command denied to user 'marco'@'localhost' for table 'projecten'

The tables:
facturen:

CREATE TABLE IF NOT EXISTS `facturen` (
  `id` int(11) NOT NULL auto_increment,
  `project_id` int(11) NOT NULL,
  `datum` int(11) NOT NULL,
  `lever_datum` int(11) NOT NULL,
  `totaal_bedrag` decimal(9,2) NOT NULL,
  `btw` decimal(9,2) NOT NULL,
  `bedrijf` varchar(40) NOT NULL,
  `contactpersoon` varchar(60) NOT NULL,
  `adres` varchar(60) NOT NULL,
  `postcode` varchar(7) NOT NULL,
  `plaats` varchar(30) NOT NULL,
  `betaald` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=201200006 ;

projecten:

CREATE TABLE IF NOT EXISTS `projecten` (
  `id` int(11) NOT NULL auto_increment,
  `titel` varchar(80) NOT NULL,
  `eigenaar` int(11) NOT NULL,
  `creatie_datum` int(11) NOT NULL,
  `eind_datum` int(11) NOT NULL,
  `totaal_bedrag` decimal(9,2) NOT NULL,
  `btw` decimal(9,2) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=201200004 ;

The strange part is that every other query on both the ‘projecten’ table and the ‘facturen’ table works completely fine, also this query works fine on two other servers of mine.

The error SELECT command denied to user ‘user’@’host’ is often caused when the currently connected MySQL User does not have a SELECT grant to the targeted Database. This could be easily fixed on a Shared Hosting plan or VPS hosting or Dedicated Server hosting:

FIX: MySQL – SELECT Command Denied To User

Depending on the hosting plan you use, you can follow the guidelines and fix this issue in less than a minute.

Shared Hosting:

1. Login to your cPanel and click on the MySQL® Databases tool which is located under the Databases section

2. Add the user you wish to grant with SELECT privileges to the database in question and make sure to provide the user with All Privileges.

cPanel Hosting from WebhostFace

VPS / Dedicated Server without WHM / cPanel:

Login via SSH as the root user and type the following:

mysql

GRANT SELECT ON database_name.* TO 'user'@'localhost';

Try the popular MySQL commands on our web hosting packages – now with NEW greatly discounted Prices!: Shared Hosting, SSD VPS Hosting, Dedicated Servers.

Понравилась статья? Поделить с друзьями:
  • Ошибка sel стиральная машина горенье
  • Ошибка security boot fail при загрузке с флешки
  • Ошибка secure boot violation invalid signature detected
  • Ошибка secret net studio 1603
  • Ошибка second boot при обновлении до windows 10