简体   繁体   English

无法打开和锁定权限表:表 'mysql.user' 不存在

[英]Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

I installed MySQL community server 5.7.10 using binary zip.我使用二进制 zip 安装了 MySQL 社区服务器 5.7.10。 I extracted the zip in c:\\mysql and created the data folder in c:\\mysql\\data .我在c:\\mysql提取了 zip 并在c:\\mysql\\data创建了数据文件夹。 I created the config file as my.ini and placed it in c:\\mysql (root folder of extracted zip).我将配置文件创建为my.ini并将其放置在c:\\mysql (解压缩的 zip 的根文件夹)中。 Below is the content of the my.ini file下面是my.ini文件的内容

# set basedir to your installation path
basedir=C:\mysql
# set datadir to the location of your data directory
datadir=C:\mysql\data

I'm trying to start MySQL using mysqld --console , but the process is aborted with the below error.我正在尝试使用mysqld --console启动 MySQL,但该过程因以下错误而中止。

2015-12-29T18:04:01.141930Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2015-12-29T18:04:01.141930Z 0 [ERROR] Aborting 

Any help on this will be appreciated.对此的任何帮助将不胜感激。

You have to initialize the data directory by running the following command您必须通过运行以下命令来初始化数据目录

mysqld --initialize [with random root password] mysqld --initialize [使用随机root密码]

mysqld --initialize-insecure [with blank root password] mysqld --initialize-insecure [root 密码为空]

The mysql_install_db script also needs the datadir parameter: mysql_install_db脚本还需要datadir参数:

mysql_install_db --user=root --datadir=$db_datapath

On Maria DB you use the install script mysql_install_db to install and initialize.在 Maria DB 上,您使用安装脚本mysql_install_db来安装和初始化。 In my case I use an environment variable for the data path.就我而言,我为数据路径使用环境变量。 Not only does mysqld need to know where the data is (specified via commandline), but so does the install script. mysqld不仅需要知道数据在哪里(通过命令行指定),而且安装脚本也需要知道。

mysqld --initialize to initialize the data directory then mysqld & mysqld --initialize 初始化数据目录然后mysqld &

If you had already launched mysqld& without mysqld --initialize you might have to delete all files in your data directory如果您已经在没有 mysqld --initialize 的情况下启动了 mysqld&,您可能必须删除数据目录中的所有文件

You can also modify /etc/my.cnf to add a custom path to your data directory like this :您还可以修改 /etc/my.cnf 以将自定义路径添加到您的数据目录,如下所示:

[mysqld]
...  
datadir=/path/to/directory

As suggested above, i had similar issue with mysql-5.7.18,如上所述,我在 mysql-5.7.18 上遇到了类似的问题,
i did this in this way我是这样做的

1. Executed this command from "MYSQL_HOME\\bin\\mysqld.exe --initialize-insecure" 1.从“MYSQL_HOME\\bin\\mysqld.exe --initialize-insecure”执行这个命令
2. then started "MYSQL_HOME\\bin\\mysqld.exe" 2.然后启动“MYSQL_HOME\\bin\\mysqld.exe”
3. Connect workbench to this localhost:3306 with username 'root' 3. 使用用户名“root”将工作台连接到这个 localhost:3306
4. then executed this query "SET PASSWORD FOR 'root'@'localhost' = 'root';" 4.然后执行这个查询“SET PASSWORD FOR 'root'@'localhost' = 'root';”

password was also updated successfully.密码也更新成功。

I had the same problem.我有同样的问题。 For some reason --initialize did not work.由于某种原因--initialize不起作用。 After about 5 hours of trial and error with different parameters, configs and commands I found out that the problem was caused by the file system.在使用不同的参数、配置和命令进行了大约 5 个小时的反复试验后,我发现问题是由文件系统引起的。

I wanted to run a database on a large USB HDD drive.我想在大型 USB 硬盘驱动器上运行数据库。 Drives larger than 2 TB are GPT partitioned!大于 2 TB 的驱动器是 GPT 分区的! Here is a bug report with a solution:这是一个带有解决方案的错误报告:

https://bugs.mysql.com/bug.php?id=28913 https://bugs.mysql.com/bug.php?id=28913

In short words: Add the following line to your my.ini:简而言之:将以下行添加到您的 my.ini 中:

innodb_flush_method=normal

I had this problem with mysql 5.7 on Windows.我在 Windows 上使用 mysql 5.7 时遇到了这个问题。

My problem was caused by an incorrect db restore.我的问题是由不正确的数据库还原引起的。 When I dumed the db it also picked up the system mysql tables because I added a space after -p as mentioned here: mysqldump is dumping undesired system tables当我删除 db 时,它也获取了系统 mysql 表,因为我在-p之后添加了一个空格,如下所述: mysqldump is dumping undesired system tables

Launching the docker instance would work, then I'd restore (and corrupt) the db and it would still keep running, but after restarting it would Exit with error code 1.启动 docker 实例会起作用,然后我会恢复(并损坏)数据库并且它仍然会继续运行,但是在重新启动后它会退出并显示错误代码 1。

The solution was to dump and restore properly without the system tables.解决方案是在没有系统表的情况下正确转储和恢复。

I face the same issue with version Mysql 5.7.33 when the server has rebooted.当服务器重新启动时,我在Mysql 5.7.33版本中遇到了同样的问题。 I fix it by copy other server user files scp /var/lib/mysql/mysql/user.* root@dest:/var/lib/mysql/mysql .我通过复制其他服务器用户文件scp /var/lib/mysql/mysql/user.* root@dest:/var/lib/mysql/mysql修复它。

I installed MySQL community server 5.7.10 using binary zip.我使用二进制zip安装了MySQL社区服务器5.7.10。 I extracted the zip in c:\\mysql and created the data folder in c:\\mysql\\data .我在c:\\mysql提取了zip文件,并在c:\\mysql\\data创建了数据文件夹。 I created the config file as my.ini and placed it in c:\\mysql (root folder of extracted zip).我将配置文件创建为my.ini ,并将其放置在c:\\mysql (提取的zip的根文件夹)中。 Below is the content of the my.ini file以下是my.ini文件的内容

# set basedir to your installation path
basedir=C:\mysql
# set datadir to the location of your data directory
datadir=C:\mysql\data

I'm trying to start MySQL using mysqld --console , but the process is aborted with the below error.我正在尝试使用mysqld --console启动MySQL,但是该过程因以下错误而中止。

2015-12-29T18:04:01.141930Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2015-12-29T18:04:01.141930Z 0 [ERROR] Aborting 

Any help on this will be appreciated.任何帮助,将不胜感激。

暂无
暂无

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

相关问题 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/mariadb“无法打开和锁定权限表:表‘mysql.servers’不存在” - Mysql/mariadb "Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist" 致命错误:无法打开和锁定权限表:表 'mysql.host' 不存在 - Fatal error: Can't open and lock privilege tables: Table 'mysql.host' 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.user' 不存在:错误 - Table 'mysql.user' doesn't exist:ERROR 移动数据后无法运行mysql(严重错误:无法打开和锁定特权表:表'mysql.host'不存在) - Cannot run mysql after moving data (Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist) 无法重新启动 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 gives me:“Can't open and lock privilege tables: Table 'host' is read only” MySQL致命错误:无法打开和锁定权限表:文件格式“用户”不正确 - MySQL Fatal error: Can't open and lock privilege tables: Incorrect file format 'user' 生成根密码时发生mysql错误,表'mysql.user'不存在' - mysql error at root password generation, Table 'mysql.user' doesn't exist'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM