在win10手动安装mysql遇到的错误小记,版本:mysql-5.7.36
my.ini配置文件如下:
[mysql] basedir=D:softwaremysql-5.7.36 datadir=D:softwaremysql-5.7.36data port=3306 skip-grant-tables
我发现不论是正反斜杠、双斜杠、中文注释对于配置文件是没有影响的,这里运行命令的前提是管理员权限。运行命令如下:
cd /d D:softwaremysql-5.7.36bin
mysqld -install
//输出Service successfully installed.
mysqld --initalize-insecure --user=mysql
//执行初始化需要先新建data文件,真奇怪。。。这里初始化成功是没有提示信息的
net start mysql
//启动mysql
第一次初始化报错了说是没找到data文件夹,只好新建了一个data文件夹(看很多教程都说不要自己建。),然后启动mysql又报错了:
net start mysql MySQL MySQL 服务无法启动。服务没有报告任何错误。请键入 NET HELPMSG 3534 以获得更多的帮助。
没有错误信息。
输入mysqld --console查看错误日志,如下(摘要):
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
[Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
[Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened
[Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-03-09T09:35:27.100154Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-03-09T09:35:27.101978Z 0 [Warning] CA certificate ca.pem is self signed.
[Warning] Failed to open optimizer cost constant tables2022-03-09T09:35:27.108005Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2022-03-09T09:35:27.108157Z 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.
2022-03-09T09:35:27.108736Z 0 [ERROR] Aborting
[Note] Binlog end
Shutting down plugin 'ngram'
……
[Note] mysqld: Shutdown complete
两个致命错误,继续搜……
找了一圈,总算找着一个和我一样情况的兄弟:
WIN10下MYSQL无法运行问题 - 残风卷云 - 博客园 (cnblogs.com)
按他的方法,把data清空,再次执行 mysqld --initialize --user=mysql --console
还是爆警告,打开data一看,已经生成了mysql等三个文件夹,之前是没有的:
再次net start mysql,成功了!
接下来登录MySQL,输入mysql -u root -p,报错:
mysql: [ERROR] unknown variable 'basedir=D:/software/mysql-5.7.36/'
配置文件首行改为[mysqld],输入mysql -u root -p 再次报错:
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
重启后成功进入!修改了配置文件一定要停止再重启。命令net stop/start mysql



