mysql说root@localhost是用空密码创建的!但是什么也没发生。我错过什么了吗?

mysql说root@localhost是用空密码创建的!但是什么也没发生。我错过什么了吗?,mysql,macos,macos-sierra,Mysql,Macos,Macos Sierra,这开始是一个根密码重置练习,但遇到了各种错误:当前在3306端口上出现冲突。如果您想跳过前面的步骤,请参阅问题的最后几段(我只是在取得进展的同时不断更新问题和标题)。多谢各位 我有一个安装了mysql的mac,但我记不起密码,因此我一直在尝试使用:https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html(部分:B.5.3.2.2重置根密码:Unix和类Unix系统) 运行此命令时: mysqld--init file=/

这开始是一个根密码重置练习,但遇到了各种错误:当前在3306端口上出现冲突。如果您想跳过前面的步骤,请参阅问题的最后几段(我只是在取得进展的同时不断更新问题和标题)。多谢各位

我有一个安装了mysql的mac,但我记不起密码,因此我一直在尝试使用:
https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
(部分:B.5.3.2.2重置根密码:Unix和类Unix系统)

运行此命令时:
mysqld--init file=/home/me/mysql init&

我得到了这个错误:

`[1] 70374
Deepaks-MacBook-Air:data root# 2018-05-06T08:35:29.269289Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T08:35:29.271535Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T08:35:29.272815Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 70374 ...
2018-05-06T08:35:29.290319Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-05-06T08:35:29.290429Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2018-05-06T08:35:29.290472Z 0 [ERROR] Aborting

2018-05-06T08:35:29.290494Z 0 [Note] Binlog end
2018-05-06T08:35:29.293896Z 0 [Note] mysqld: Shutdown complete

[1]+  Done(1)`
因此,我尝试以下命令:
sudo/usr/local/mysql/support files/mysql.server start--init file=/usr/local/mysql/data/mysql init

但现在我得到了这个错误:
错误!服务器在不更新PID文件(/usr/local/mysql/data/Deepaks MacBook Air.local.PID)的情况下退出。

以下是日志文件的内容:

2018-05-06T08:03:52.799002Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T08:03:52.801385Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T08:03:52.801495Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.21) starting as process 69954 ...
2018-05-06T08:03:52.810622Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2018-05-06T08:03:52.832273Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-06T08:03:52.832306Z 0 [Note] InnoDB: Uses event mutexes
2018-05-06T08:03:52.832313Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-06T08:03:52.832319Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-06T08:03:52.832780Z 0 [Note] InnoDB: Number of pools: 1
2018-05-06T08:03:52.833783Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-06T08:03:52.838027Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-06T08:03:52.856588Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-06T08:03:52.876537Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-06T08:03:52.899436Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-06T08:03:52.900043Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-06T08:03:52.944160Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-06T08:03:52.946174Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-06T08:03:52.946218Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-06T08:03:52.946641Z 0 [Note] InnoDB: Waiting for purge to start
2018-05-06T08:03:53.001405Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 2551377
2018-05-06T08:03:53.001712Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql-5.7.21-macos10.13-x86_64/data/ib_buffer_pool
2018-05-06T08:03:53.001962Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-05-06T08:03:53.019470Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-05-06T08:03:53.020660Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 13:33:53
2018-05-06T08:03:53.026724Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2018-05-06T08:03:53.026844Z 0 [Note] IPv6 is available.
2018-05-06T08:03:53.026872Z 0 [Note]   - '::' resolves to '::';
2018-05-06T08:03:53.026926Z 0 [Note] Server socket created on IP: '::'.
2018-05-06T08:03:53.087999Z 0 [Note] Event Scheduler: Loaded 0 events
2018-05-06T08:03:53.088163Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.7.21'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2018-05-06T08:12:46.664218Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2018-05-06T09:35:55.013341Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 2948657ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
有什么问题,如何解决

PS:我已经提到了这两个问题,并且正在尝试所有答案中的几乎所有解决方案—重置权限以删除
/usr/local/var/mysql
中的所有文件。这仍然是同一个问题,我怀疑这与mysqld没有正常运行有关——是否有一种特殊的方式将其作为root运行。我目前正试图通过
sudo-I
在终端中以root模式运行。有人能帮我调试一下吗?谢谢

mysql版本:

> mysql --version
mysql  Ver 14.14 Distrib 5.7.21, for osx10.12 (x86_64) using  EditLine wrapper
更新:我阅读了安全文档-显然你不应该以root模式运行它。因此,我使用
exit
注销

现在,我得到以下情况:

Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init &
[2] 72004
Deepaks-MacBook-Air:mysql deepak$ mysqld: Can't change dir to '/usr/local/var/mysql/' (Errcode: 2 - No such file or directory)
2018-05-06T10:59:48.877152Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T10:59:48.880902Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T10:59:48.881775Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72004 ...
2018-05-06T10:59:48.897332Z 0 [Warning] Can't create test file /usr/local/var/mysql/Deepaks-MacBook-Air.lower-test
2018-05-06T10:59:48.897395Z 0 [Warning] Can't create test file /usr/local/var/mysql/Deepaks-MacBook-Air.lower-test
2018-05-06T10:59:48.897593Z 0 [ERROR] failed to set datadir to /usr/local/var/mysql/
2018-05-06T10:59:48.897607Z 0 [ERROR] Aborting

2018-05-06T10:59:48.897624Z 0 [Note] Binlog end
2018-05-06T10:59:48.899188Z 0 [Note] mysqld: Shutdown complete
我怀疑这是由于删除了我的/usr/local/var/mysql目录,正如在另一个答案中所建议的那样。我已经用
rm-rf
删除了它。我在
var
中创建了一个新的dir
mkdir-mysql
,然后运行
mysqld--init file=/usr/local/mysql/data/mysql-init&
,它最初会给我一个pid,但是日志会询问我3306端口是否已经被占用:

2018-05-06T11:04:14.215705Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2018-05-06T11:04:14.218651Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-05-06T11:04:14.225038Z 0 [Note] Salting uuid generator variables, current_pid: 72031, server_start_time: 1525604653, bytes_sent: 0, 
2018-05-06T11:04:14.225601Z 0 [Note] Generated uuid: '36553708-511d-11e8-ba65-c83fe4b8ed7b', server_start_time: 1828179975261387404, bytes_sent: 140216128435712
2018-05-06T11:04:14.225667Z 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: 36553708-511d-11e8-ba65-c83fe4b8ed7b.
2018-05-06T11:04:14.241961Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T11:04:14.391057Z 0 [Note] Auto generated SSL certificates are placed in data directory.
2018-05-06T11:04:14.391874Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T11:04:14.490103Z 0 [Note] Auto generated RSA key files are placed in data directory.
2018-05-06T11:04:14.499147Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-05-06T11:04:14.499239Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2018-05-06T11:04:14.499424Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-05-06T11:04:14.499495Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
2018-05-06T11:04:14.499503Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2018-05-06T11:04:14.499536Z 0 [ERROR] Aborting
实际上,我的
/usr/local/
-
mysql
mysql-5.7.21-macos10.13-x86_64
中有两个文件夹。整个过程到目前为止,我一直在“mysql
文件夹中运行,还没有真正接触到
mysql-5.7.21-macos10.13-x86_64`。它们内部似乎有相同的目录结构

另外,当我执行ps aux | grep mysql时,我会得到三个进程:

Deepaks-MacBook-Air:local deepak$ ps aux | grep mysql
deepak           72071 100.0  0.0  2443044   1992 s002  S+    4:44PM   0:00.01 grep mysql
_mysql           71985   0.0  0.2  2852472  13132   ??  Ss    4:25PM   0:00.66 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid --keyring-file-data=/usr/local/mysql/keyring/keyring --early-plugin-load=keyring_file=keyring_file.so
root             71967   0.0  0.1  2460804   7992 s002  T     4:23PM   0:00.03 sudo mysqld --init-file=/usr/local/mysql/data/mysql-init
然而,当我继续杀死第二个或第三个时,当我再次杀死它们时,它们就会再次出现

此外,我通常使用portforwarding连接到远程MySQL主机。因此,每隔一段时间,我会在本地脚本中运行ssh-fNT-l3307:localhost:3306-I~/key/deepak_ubuntu_16feb.pemubuntu@ec2-AWS-HOS-TNA-ME.compute-1.amazonaws.com“

这会是一场冲突吗

更新: 好的,我忽略了另一个目录,只是简单地更改了端口,这似乎避免了冲突,但现在有一个不同的问题:mysql.sock.lock无法访问

Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init --port=3308 &
[2] 72160
Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T11:32:45.441642Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T11:32:45.443453Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T11:32:45.444202Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72160 ...
2018-05-06T11:32:45.463651Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-05-06T11:32:45.478310Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-06T11:32:45.478366Z 0 [Note] InnoDB: Uses event mutexes
2018-05-06T11:32:45.478375Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-06T11:32:45.478384Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-06T11:32:45.480830Z 0 [Note] InnoDB: Number of pools: 1
2018-05-06T11:32:45.483263Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-06T11:32:45.487576Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-06T11:32:45.507092Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-06T11:32:45.538289Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-06T11:32:45.565701Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-06T11:32:45.565987Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-06T11:32:45.622322Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-06T11:32:45.623627Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-06T11:32:45.623652Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-06T11:32:45.623974Z 0 [Note] InnoDB: Waiting for purge to start
2018-05-06T11:32:45.678385Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 1209980
2018-05-06T11:32:45.678936Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2018-05-06T11:32:45.680200Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-05-06T11:32:45.680346Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 17:02:45
mysqld: Table 'mysql.plugin' doesn't exist
2018-05-06T11:32:45.680885Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-05-06T11:32:45.684081Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T11:32:45.686185Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-05-06T11:32:45.686212Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2018-05-06T11:32:45.691365Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T11:32:45.691562Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2018-05-06T11:32:45.693912Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3308
2018-05-06T11:32:45.694589Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2018-05-06T11:32:45.694853Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-05-06T11:32:45.695047Z 0 [ERROR] Could not open unix socket lock file /tmp/mysql.sock.lock.
2018-05-06T11:32:45.695067Z 0 [ERROR] Unable to setup unix socket lock file.
2018-05-06T11:32:45.695092Z 0 [ERROR] Aborting
好的,所以我进入了
/tmp/
并尝试检查文件的权限-以下是结果:

Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock.lock 
16777220 3413029 -rw------- 1 _mysql wheel 0 6 "May  6 16:25:35 2018" "May  6 16:25:35 2018" "May  6 16:25:35 2018" "May  6 16:25:35 2018" 4096 8 0 mysql.sock.lock
Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock
16777220 3413030 srwxrwxrwx 1 _mysql wheel 0 0 "May  6 16:25:44 2018" "May  6 16:25:44 2018" "May  6 16:25:44 2018" "May  6 16:25:35 2018" 4096 0 0 mysql.sock
我正在尝试这篇文章的解决方案,所以
https://stackoverflow.com/questions/34954455/mysql-daemon-lock-issue
,更改所有者的回答无效。我对解除锁定有点犹豫

好的,这个帖子:
https://support.rackspace.com/how-to/checking-linux-file-permissions-with-ls/
非常简洁地解释了如何读取这些权限——显然在我的例子中,mysql用户和wheel分别是所有者和组。这是没有意义的,因为我从来没有在
.whl
上下文之外的任何东西中遇到过
wheel
,而且我在今天之前从未遇到过_mysql。我之前尝试过使用
su-\u mysql
更改为该用户,但我猜不出密码-不确定mysql是否默认设置了该密码,在这种情况下,我现在很困惑

更新: 好的,我解决了我的食物问题:

Deepaks-MacBook-Air:tmp deepak$ sudo chown deepak mysql.sock
Deepaks-MacBook-Air:tmp deepak$ sudo chown deepak mysql.sock.lock
Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock.lock
16777220 3413029 -rw------- 1 deepak wheel 0 6 "May  6 16:25:35 2018" "May  6 16:25:35 2018" "May  6 17:26:54 2018" "May  6 16:25:35 2018" 4096 8 0 mysql.sock.lock
Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock
16777220 3413030 srwxrwxrwx 1 deepak wheel 0 0 "May  6 16:25:44 2018" "May  6 16:25:44 2018" "May  6 17:26:22 2018" "May  6 16:25:35 2018" 4096 0 0 mysql.sock
但是,这会导致另一个错误:
无法打开和锁定特权表:表'mysql.user'不存在

Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init --port=3308 &
[2] 72244
Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T11:57:33.454182Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T11:57:33.456455Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T11:57:33.457505Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72244 ...
2018-05-06T11:57:33.470925Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-05-06T11:57:33.482170Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-06T11:57:33.482216Z 0 [Note] InnoDB: Uses event mutexes
2018-05-06T11:57:33.482224Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-06T11:57:33.482231Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-06T11:57:33.486263Z 0 [Note] InnoDB: Number of pools: 1
2018-05-06T11:57:33.489217Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-06T11:57:33.494624Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-06T11:57:33.513877Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-06T11:57:33.546517Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-06T11:57:33.575022Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-06T11:57:33.575404Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-06T11:57:33.620985Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-06T11:57:33.622662Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-06T11:57:33.622693Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-06T11:57:33.623068Z 0 [Note] InnoDB: Waiting for purge to start
2018-05-06T11:57:33.677963Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 1209999
2018-05-06T11:57:33.679157Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2018-05-06T11:57:33.680426Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 17:27:33
2018-05-06T11:57:33.681987Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2018-05-06T11:57:33.684004Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-05-06T11:57:33.688066Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T11:57:33.690386Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-05-06T11:57:33.690502Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2018-05-06T11:57:33.694745Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T11:57:33.694856Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2018-05-06T11:57:33.695461Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3308
2018-05-06T11:57:33.696028Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2018-05-06T11:57:33.696184Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-05-06T11:57:33.700436Z 0 [Warning] Failed to open optimizer cost constant tables

2018-05-06T11:57:33.704524Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

2018-05-06T11:57:33.704983Z 0 [ERROR] Aborting
好的,通过使用
chown
将所有者从_mysql更改为我的普通帐户,问题得到了解决,但现在问题是:

Deepaks-MacBook-Air:mysql deepak$ mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 &
[2] 72328
Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T12:21:01.547203Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T12:21:01.550869Z 0 [ERROR] Can't find error-message file '/usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2018-05-06T12:21:01.557694Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-05-06T12:21:01.557751Z 0 [ERROR] Aborting
我是这样解决的:共享文件夹没有mysql目录,而是在英文目录中有errmsg.sys,我只是将此文件复制到我在共享文件夹中创建的一个新目录中:
mkdir mysql

这起了作用,但随后表明:

Can't create directory '/usr/local/mysql/data/' (Errcode: 13 - Permission denied)
2018-05-06T12:49:13.313038Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T12:49:13.316262Z 0 [Warning] Using pre 5.5 semantics to load error messages from /usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/.
2018-05-06T12:49:13.316285Z 0 [Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2018-05-06T12:49:13.322333Z 0 [ERROR] Aborting
使用chown,我将mysql目录的所有者更改为我的常规用户帐户(奇怪的是,mysql-5.7.21-macos10.13-x86_64目录不会将其所有者从组从root和wheel更改为任何内容,即使我使用它)

现在,来自
/usr/local/mysql/
mysqld--initialize unsecure--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--init file=/usr/local/mysql/init--port=3308&
命令显示了以下输出:

Deepaks-MacBook-Air:local deepak$ mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 &
[2] 72460
Deepaks-MacBook-Air:local deepak$ 2018-05-06T12:52:51.009693Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T12:52:51.013089Z 0 [Warning] Using pre 5.5 semantics to load error messages from /usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/.
2018-05-06T12:52:51.013108Z 0 [Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2018-05-06T12:52:51.020232Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2018-05-06T12:52:51.549560Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-05-06T12:52:51.614133Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-06T12:52:51.692927Z 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: 630bcd34-512c-11e8-934a-45e8be00c2cf.
2018-05-06T12:52:51.711501Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T12:52:51.847929Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T12:52:51.903182Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
这看起来不错,但什么都没有发生。是这样吗?我现在可以开始使用SequelPro连接到“localhost:3308”了吗?或者还有其他一些需要解决的问题,比如设置临时密码吗?在此之前,我是否需要进入另一个终端窗口尝试
mysql-u root
,然后让它继续运行或者做些什么

另外,当我不使用
ps aux|grep mysql
时,它会像以前一样显示三个进程,但不会显示mysqld现在显示的
72460
进程。这是我需要关注的问题吗

这是我第一次这样做,我害怕现在就做任何事情,以免破坏最后几个小时的努力来解决这个问题

我如何解决这个问题
Deepaks-MacBook-Air:App deepak$ mysqladmin -u root
mysqladmin  Ver 8.42 Distrib 5.7.21, for osx10.12 on x86_64
Copyright (c) 2000, 2018, 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.

Administration program for the mysqld daemon.
Usage: mysqladmin [OPTIONS] command command....