开源社区的解决办法,有效。https://www.oschina.net/question/1244397_2138435 。
我的错误是data文件下,文件类型为“ERR文件”里'FEDERATED' is disabled. Table 'mysql.plugin' doesn't exist。(无法启动mysql服务) 然后按照上面 生成随机密码,初始化数据库。网上找了很多解决方法,csdn,百度知道,stackoverflow等等 ,都没有很好的效果。但是上面这个解决了我无法启动mysql服务的问题。很感谢Tuesday大师的回答!
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>cd /d "C:\Program Files\MySQL\MySQL Server 5.7\bin"
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld -install
Service successfully installed.
C:\Program Files\MySQL\MySQL Server 5.7\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务无法启动。
服务没有报告任何错误。
请键入 NET HELPMSG 3534 以获得更多的帮助。
/*查看windows日志是因为
Fatal error:
Can't open and lock privilege tables: Table 'mysql.user' doesn't exist */
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize --user=mysql --console
2017-12-25T14:47:42.131665Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timesta
mp server option (see documentation for more details).
2017-12-25T14:47:42.147265Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-12-25T14:47:42.163865Z 0 [ERROR] Aborting
//将data文件夹里的文件全部清空后,再执行命令
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize --user=mysql --console
2017-12-25T14:48:30.765017Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timesta
mp server option (see documentation for more details).
2017-12-25T14:48:41.833846Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-12-25T14:48:43.839051Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-12-25T14:48:44.512253Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has
been started. Generating a new UUID: b4b8e0ab-e982-11e7-b303-00ff2ee04b9c.
2017-12-25T14:48:44.605854Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-12-25T14:48:55.834683Z 1 [Note] A temporary password is generated for root@localhost: Xg2huGprf*C&
//这个Xg2huGprf*C&密码等会儿要用。
C:\Program Files\MySQL\MySQL Server 5.7\bin>
C:\Program Files\MySQL\MySQL Server 5.7\bin>net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password=password('root')
->
mysql_install_db --user=mysql 初始化数据库即可 百度下:怎么初始化数据库
datadir目录的权限设置的不对。