简体   繁体   English

表 'mysql.user' 不存在:错误

[英]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.我正在为一个java程序在mysql中创建一个数据库。我的程序在我的朋友系统中运行良好。但是我的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'.场景:我在我的 Mac 上使用“自制升级”更新了 MySQL 版本。 Afterwards, some stuff worked, but other commands raised the error described in the question.之后,有些东西起作用了,但其他命令引发了问题中描述的错误。

Looks like something is messed up with your MySQL installation.看起来您的 MySQL 安装有些问题。 The mysql.user table should definitely exist. mysql.user表肯定存在。 Try running the command below on your server to create the tables in the database called mysql :尝试在您的服务器上运行以下命令以在名为mysql的数据库中创建表:

mysql_install_db

If that doesn't work, maybe the permissions on your MySQL data directory are messed up.如果这不起作用,则可能是您的 MySQL 数据目录的权限被弄乱了。 Look at a "known good" installation as a reference for what the permissions should be.查看“已知良好”安装作为权限应该是什么的参考。

You could also try re-installing MySQL completely.您也可以尝试完全重新安装 MySQL。

Same issue here as lxxxvi describes.这里与 lxxxvi 描述的问题相同。 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:尝试检查 mysql.user 是否存在:

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.或者您可能必须清理(完全删除它)并重新安装 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.检查数据库 mysql 和表用户,如上所示,如果该 dosent 工作,您的 mysql 安装不正确。

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如果找不到此表,请查看以下链接以重建数据库How to recover/recreate mysql's default 'mysql' database

尝试运行mysqladmin reload ,它位于 mac 上的/usr/loca/mysql/bin/中。

'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'.结果显示“未选择数据库,通过在侧边栏中的 SCHEMAS 列表中双击其名称来选择要使用的默认数据库”。 Will solve the issue and it worked for me very well.将解决这个问题,它对我很有用。

当您在空数据库上运行授权/权限查询时,有时会发生这种情况

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 生成根密码时发生mysql错误,表'mysql.user'不存在' - mysql error at root password generation, Table 'mysql.user' doesn't exist' MariaDB 10.4.10 错误 1146 (42S02):表 'mysql.user' 不存在 - MariaDB 10.4.10 ERROR 1146 (42S02): Table 'mysql.user' doesn't exist Docker中的Bootstraping Percona Xtradb Cluster出现错误:无法打开和锁定特权表:表'mysql.user'不存在 - Bootstraping Percona Xtradb Cluster in Docker gives the error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 无法打开和锁定权限表:表 'mysql.user' 不存在 - Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 服务mysql启动在我的日志文件中留下“特权表:表'mysql.user'不存在”并且服务器失败 - service mysql start leaves “privilege tables: Table 'mysql.user' doesn't exist” in my log file and the server fails 无法重新启动 MySQL Docker 容器,出现“无法打开 mysql.plugin 表”和“表 'mysql.user' 不存在”等错误 - Cannot restart the MySQL Docker container, gives errors like `Can't open the mysql.plugin table` and `Table 'mysql.user' doesn't exist` mySQL上的mysql.user表 - mysql.user table on mySQL Mysql.User不显示所有特权 - Mysql.User doesn't show all of the privileges 在mysql中重新创建一个“ mysql.user”表 - Recreate a `mysql.user` table in mysql 如何修复mysql.user表? - How to repair mysql.user table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM