Table "mysql.user" does not exist: ERROR

I am creating db in mysql for a java program. My program works well on my friends system. But I have some problems with my mysql.

Request 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 can not create any user for my db. Please help

+6
source share
5 answers

It looks like something went wrong with your MySQL installation. The mysql.user table must exist. Try running the following command on your server to create tables in a database called mysql :

 mysql_install_db 

If this does not work, the permissions on your MySQL data directory may be mixed up. Take a look at the β€œwell-known” installation as a reference to what permissions should be.

You can also try reinstalling MySQL completely.

+2
source

Your database may be corrupted. Try checking if mysql.user exists:

 use mysql; select * from user; 

If they are missing, you can try to recreate the tables using

mysql_install_db

or you may need to clean (completely remove it) and reinstall MySQL.

+2
source

You can run the following query to check for a user table.

 SELECT * FROM information_schema.TABLES WHERE TABLE_NAME LIKE '%user%' 

See if you can find a string with the following values ​​in

 mysql user BASE TABLE MyISAM 

If you cannot find the following link to restore the database in this table How to restore / recreate the default mysql database mysql

+1
source
  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 mysql database and user table as shown above, if this dosage function works, your mysql installation is not suitable.

use the following command, as mentioned in another article, to set tables again

 mysql_install_db 
0
source

Try running mysqladmin reload , which is located in /usr/loca/mysql/bin/ on a Mac.

0
source

Source: https://habr.com/ru/post/949963/


All Articles