折腾了一上午,遇到的各种错误:
错误一:安装后,终端执行 mysql 或者执行 mysql -u root -p
时报错:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
错误二:为解决错误一, 尝试执行
mysqld --user=root --skip-grant-tables &
报错:
2020-12-03T02:43:04.627716Z 0 [System] [MY-010116] [Server] /usr/local/mysql-8.0.22-macos10.15-x86_64/bin/mysqld (mysqld 8.0.22) starting as process 10786
2020-12-03T02:43:04.630514Z 0 [Warning] [MY-010091] [Server] Can't create test file /usr/local/mysql-8.0.22-macos10.15-x86_64/data/mysqld_tmp_file_case_insensitive_test.lower-test
2020-12-03T02:43:04.630524Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql-8.0.22-macos10.15-x86_64/data/ is case insensitive
2020-12-03T02:43:04.630895Z 0 [Warning] [MY-010122] [Server] One can only use the --user switch if running as root
2020-12-03T02:43:04.630938Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/usr/local/mysql-8.0.22-macos10.15-x86_64/data/' (OS errno: 13 - Permission denied)
2020-12-03T02:43:04.630991Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-12-03T02:43:04.631143Z 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0.22-macos10.15-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.22) MySQL Community Server - GPL.
尝试了查到的各个方法无果。
错误三:还是为了解决错误一,尝试:
cd /usr/local/mysql/bin
sudo su
输入开机密码 回车
sh-3.2# ./mysqld_safe --skip-grant-tables &
报错:
[3] 1602
sh-3.2# 2020-12-03T03:44:22.6NZ mysqld_safe Logging to '/usr/local/mysql-8.0.22-macos10.15-x86_64/data/ing-3.local.err'.
2020-12-03T03:44:22.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-8.0.22-macos10.15-x86_64/data
mysql2020-12-03T03:44:26.6NZ mysqld_safe mysqld from pid file /usr/local/mysql-8.0.22-macos10.15-x86_64/data/ing-3.local.pid ended
2020-12-03T03:46:02.6NZ mysqld_safe mysqld from pid file /usr/local/mysql-8.0.22-macos10.15-x86_64/data/ing-3.local.pid ended
错误四:偶然发现,mysql服务一会自动开启一会自动关闭,查看原因的话,可以在偏好设置里的mysql下点选Configuration 查看Error Log
error.png最后,在抓狂的边缘,我又又又劝自己再尝试重装一次mysql...没想到成了。
在重装之前,一定要确保将已安装的mysql彻底卸载干净,如何卸载看这篇
一. 官网下载
版本选择.png选择第一个就好了。
二.下载完成,开始安装 一路继续 ... 多图预警!!!
1.png三. 选择密码加密类型 ,选第一个就行。 2.png 四. 为root用户定义一个密码,这个要记住!以后要用!
3.png剩下的一路点继续,完成!
完成上述操作后,这时候应该在偏好设置里能看到mysql服务小海豚已经有了,进入,开启服务后,重点来了!这里有一个初始化操作initialize Database
你最好点一下
!不然后续可能有麻烦事,比如上面的错误三
弹窗提示输入你在安装时设置的密码,ok即可。
5.png
然后重新开启mysql服务并打开终端,输入 mysql -u root -p , 输入刚才设置的密码,终于来了~~
ok.png
网友评论