permission errors on database for full access user - mysql

I am getting an error (on MySQL 5.7.25-google in Google cloud while locally MySQL 5.7.29, it works fine)
Google Cloud, I run (NOTE: show tables shows this table existing from this same user!!!)
mysql> show index from customers;
ERROR 1146 (42S02): Table 'authtables.customers' doesn't exist
and locally (same user and password and setup), I get
mysql> SHOW INDEX FROM customers;
+-----------+------------+------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| customers | 0 | PRIMARY | 1 | id | A | 2 | NULL | NULL | | BTREE | | |
Of course, the command SHOW TABLES; works the same on both and shows the CUSTOMERS table in both!!! grrrr.
I followed the accepted answer in the link below EXCEPT for 1 minor detail for setup of 'authservice' user to 'authtables' database...
Mysql adding user for remote access
The ONE detail is my grant statements were authtables.* so that the user had full access to the authtables database and nothing else.
NEXT is my show grants command in GCP and locally which yield the EXACT same result but in case I am missing a typo, here is the GCP then the local result
mysql> show grants for 'authservice'#'localhost';
+---------------------------------------------------------------------+
| Grants for authservice#localhost |
+---------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'authservice'#'localhost' |
| GRANT ALL PRIVILEGES ON `authtables`.* TO 'authservice'#'localhost' |
+---------------------------------------------------------------------+
2 rows in set (0.08 sec)
local result is
mysql> show grants for 'authservice'#'localhost';
+---------------------------------------------------------------------+
| Grants for authservice#localhost |
+---------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'authservice'#'localhost' |
| GRANT ALL PRIVILEGES ON `authtables`.* TO 'authservice'#'localhost' |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
For completeness...
GCP version: Server version: 5.7.25-google-log (Google)
local version: Server version: 5.7.29 MySQL Community Server (GPL)
WOW, crap, what is 5.7.25-google-log...ICK. I wonder if it has a bug here.
Also, why is grant have . when I look at my history in mysql to verify, I clearly did authtables.* EVERY time!!!
Then, what happened to the 'authservice'#'%' grant as I don't see that either?
Anyone have any idea how to setup google cloud mysql so I have a user with full access to the database so he is restricted to that database? This seems kind of like some sort of google bug or am I doing something wrong?
thanks,
Dean

OMG, google's mysql 'table names' are CASE SENSITIVE!!! what the heck.
I have to do
show index from CUSTOMERS;
OR
SHOW INDEX FROM CUSTOMERS;
BUT THIS DOES NOT WORK
show index from customers;
ouch! posted this to help the next person out hopefully.

Related

MySQL 8.0 "show columns from ..." query returns 0 rows

I am running MySQL 8.0.22 on Mac OS 11.7. Before I upgraded MySQL from 5.6, the following query worked fine.
show columns from Viewing where field="type";
But now, after upgrading to MySQL 8.0.22, I get the expected 1 row returned when I'm logged into MySQL as root:
mysql> show columns from Viewing where field="type";
+-------+------------------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------------------------------------+------+-----+---------+-------+
| type | enum('edits','other','page','preview','whole') | YES | | NULL | |
+-------+------------------------------------------------+------+-----+---------+-------+
1 row in set (0.01 sec)
But when I log in as the user I've created for the webpage that issues this query, 0 rows are returned. This user is view_pjn#localhost, and its grants are:
mysql> show grants for "view_pjn"#"localhost";
+--------------------------------------------------------------------+
| Grants for view_pjn#localhost |
+--------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `view_pjn`#`localhost` |
| GRANT SELECT, INSERT ON `blog`.`viewing` TO `view_pjn`#`localhost` |
+--------------------------------------------------------------------+
2 rows in set (0.00 sec)
But when I log into MySQL 8.0.22 as view_pjn, I get the following when I issue this query:
mysql> show columns from Viewing where field="type";
Empty set (0.00 sec)
I have searched MySQL 8.0 Manual and it would seem that as view_pjn#localhost has SELECT, INSERT privileges on blog.viewing, it ought to be able to issue a show columns from Blog.Viewing query.
If anyone can tell me why view_pjn is getting 0 rows returned, I'd really appreciate it.

MySQL Create User Operation failed

I have been trying to create a MySQL user programmatically.
$this->db->query('CREATE USER 'agit****'#'localhost'); // Using Codeigniter
It returns an error
Operation CREATE USER failed for 'agit****'#'localhost'
I have deleted the user from the mysql.user and tried again.
DROP USER 'agit****'#'localhost';
I have also tried
DROP USER 'agit****'#'%';
and
DELETE FROM `mysql.user` WHERE `user` LIKE 'agit****';
The user got deleted and then I executed the following query:
flush privileges;
and restarted the MySQL server. But no use.
I have tried to create the same user from command line, and it returns the following error code
ERROR 1396 (HY000): Operation CREATE USER failed for
Server details and version numbers
SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| innodb_version | 5.5.45 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.45 |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | x86 |
| version_compile_os | Win64 |
+-------------------------+------------------------------+
7 rows in set (0.00 sec)
Note: This error occurs only when I try to create a user which existed already.
New users can be added without any issue
I have confirmed that the User got deleted from the MySQL.User table before creating the user account again.

Connecting play framework to mysql

I have two databases in mysql:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| app |
| app_dev |
+--------------------+
I have two play framework servers running, one using app and one using app_dev. The server connecting to app is local to the machine running mysql. The server connecting to app_dev is remote. I think I've setup the permissions correctly:
mysql> show grants for 'app_dev';
+------------------------------------------------------------------+
| Grants for app_dev#% |
+------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'app_dev'#'%' IDENTIFIED BY PASSWORD 'pwd' |
| GRANT ALL PRIVILEGES ON `app_dev`.* TO 'app_dev'#'%' |
+------------------------------------------------------------------+
mysql> show grants for 'app'#'localhost';
+----------------------------------------------------------------------+
| Grants for app#localhost |
+----------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'app'#'localhost' IDENTIFIED BY PASSWORD 'pwd' |
| GRANT ALL PRIVILEGES ON `app`.* TO 'app'#'localhost' |
+----------------------------------------------------------------------+
Yet for some reason, when I try to start play on my development machine, I get the response: MySQLSyntaxErrorException: SELECT command denied to user 'app_dev'#'2.ipn.ipn.ipn' for table 'play_evolutions'.
Is it possible I've set up the permissions incorrectly? The only thing that's different here is the need for the % sign as this is a remote connection!

Table 'mysql.user' doesn't exist:ERROR

I am creating a db in mysql for a java program.My program works well in my friends system.But I have some problem with my mysql.
The query is below:
mysql> create database sampledb;
Query OK, 1 row affected (0.00 sec)
mysql> use sampledb;
Database changed
mysql> create user zebronics identified by 'zebra123';
ERROR 1146 (42S02): Table 'mysql.user' doesn't exist
I cant create any user for my db.Please help??
My solution was to run
mysql_upgrade -u root
Scenario: I updated the MySQL version on my Mac with 'homebrew upgrade'. Afterwards, some stuff worked, but other commands raised the error described in the question.
Looks like something is messed up with your MySQL installation. The mysql.user table should definitely exist. Try running the command below on your server to create the tables in the database called mysql:
mysql_install_db
If that doesn't work, maybe the permissions on your MySQL data directory are messed up. Look at a "known good" installation as a reference for what the permissions should be.
You could also try re-installing MySQL completely.
Same issue here as lxxxvi describes. Running
mysql_upgrade -u root
allowed me to then successfully enter a password that
mysql_secure_installation
was waiting for.
Your database may be corrupt. Try to check if mysql.user exists:
use mysql;
select * from user;
If these are missing you can try recreating the tables by using
mysql_install_db
or you may have to clean (completely remove it) and reinstall MySQL.
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| datapass_schema |
| mysql |
| test |
+--------------------+
4 rows in set (0.05 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables
-> ;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
23 rows in set (0.00 sec)
mysql> create user m identified by 'm';
Query OK, 0 rows affected (0.02 sec)
check for the database mysql and table user as shown above if that dosent work, your mysql installation is not proper.
use the below command as mention in other post to install tables again
mysql_install_db
You can run the following query to check for the existance of the user table.
SELECT * FROM information_schema.TABLES
WHERE TABLE_NAME LIKE '%user%'
See if you can find a row with the following values in
mysql user BASE TABLE MyISAM
If you cant find this table look at the following link to rebuild the database How to recover/recreate mysql's default 'mysql' database
Try run mysqladmin reload, which is located in /usr/loca/mysql/bin/ on mac.
'Error Code: 1046'.
This error shows that the table does not exist may sometimes be caused by having selected a different database and running a query referring to another table. The results indicates
'No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar'.
Will solve the issue and it worked for me very well.
It sometime happens when you run the grant/ privileges query on an empty database

MySQL appears to DROP USER; but user still exists in mysql.users table

I've just installed MySQL Community server (5.5.8) on Mac OS X 10.6.6.
I've been following the rules for a secure install (assign password to root, delete anonymous accounts, etc), however, there is one user account which I can't DROP:
mysql> select host, user from mysql.user;
+--------------------------------+------+
| host | user |
+--------------------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| My-Computer-Hostname.local | |
| My-Computer-Hostname.local | root |
| localhost | root |
| localhost | web |
+--------------------------------+------+
6 rows in set (0.00 sec)
mysql> drop user ''#'My-Computer-Hostname.local';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host, user from mysql.user;
+--------------------------------+------+
| host | user |
+--------------------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| My-Computer-Hostname.local | |
| My-Computer-Hostname.local | root |
| localhost | root |
| localhost | web |
+--------------------------------+------+
6 rows in set (0.00 sec)
mysql>
As you can see, MySQL reports no errors when executing the DROP USER command, but doesn't actually delete the user!
I've tried also deleting the user from within phpMyAdmin (3.3.9) and that produced the same results (i.e. reported success, no error messages, user not deleted).
I've researched this and some people suggest that GRANT may be blocking the DROP USER command, however, the user has no GRANT privileges:
mysql> SHOW GRANTS FOR ''#'My-Computer-Hostname.local';
+-----------------------------------------------------------+
| Grants for #my-computer-hostname.local |
+-----------------------------------------------------------+
| GRANT USAGE ON *.* TO ''#'my-computer-hostname.local' |
+-----------------------------------------------------------+
1 row in set (0.00 sec)
mysql> REVOKE GRANT OPTION ON *.* FROM ''#'My-Computer-Hostname.local';
ERROR 1141 (42000): There is no such grant defined for user '' on host 'my-computer-hostname.local'
I tried dropping the user again after that but it didn't drop/delete the user either.
I've checked my MySQl error logs and there's nothing unusual in there.
The MySQL manual suggests that it is possible to delete all anonymous accounts, so why can't I delete this one?
Or, to delete just the anonymous one and not the root as well:
mysql> DELETE FROM mysql.user WHERE User='' AND Host='my-computer-hostname.local';
Worked for me on 5.1.57.
This is a known bug due to your uppercase characters: http://bugs.mysql.com/bug.php?id=62255
Use the suggestion from user douger as a workaround
You can still delete the records from the user table:
mysql> DELETE FROM user WHERE host='my-computer-hostname.local';
Query OK, 2 rows affected (0.00 sec)
This method was used prior to MySQL 4.1...
MySQL includes an anonymous user account that allows anyone to connect into the MySQL server without having a user account. This is meant only for testing, and should be removed before the database server is put into a production environment.
Run the following SQL script against the MySQL server to remove the anonymous user account:
DELETE FROM mysql.user WHERE User='';
After making changes to permissions/user accounts, make sure you flush the provilege tables using the following command:
FLUSH PRIVILEGES;