gpt4 book ai didi

Mysql 连接到服务器 : Access denied for user root@localhost

转载 作者:IT王子 更新时间:2023-10-28 23:44:50 26 4
gpt4 key购买 nike

edit9:是否有可能我只是缺少对文件夹的一些权限?我真的非常感谢一些更多的建议..

编辑 3:由于这篇文章没有得到足够多的回复,所以我尽快完成这篇文章是绝对重要的,我重建了我的帖子以显示我认为到目前为止我已经扣除的内容。

注意:通过许多不同的命令正常登录根本不起作用。

我的流程:

  • 删除运行以下命令的 mysql(我忘记了什么吗?):
  • sudo rm /usr/local/mysql
    sudo rm -rf /usr/local/mysql*
    sudo rm -rf /Library/StartupItems/MySQLCOM
    sudo rm -rf /Library/PreferencePanes/MySQL*
    rm -rf ~/Library/PreferencePanes/MySQL*
    sudo rm -rf /Library/Receipts/mysql*
    sudo rm -rf /Library/Receipts/MySQL*
    sudo rm -rf /var/db/receipts/com.mysql.*
  • 已下载 mysql-5.7.9-osx10.10-x86_64.dmg来自 http://dev.mysql.com/downloads/mysql/
  • 已安装 mysql-5.7.9-osx10.9-x86_64.pkg在标准位置使用标准安装。 (为什么我下载 10.10 时 pkg 是 10.9?我的 OS X 版本是 10.10 yosemite)
  • 我收到一条通知,提示已创建 root@localhost 的临时密码。我写得很完美。

  • 这就是问题开始的地方。
  • 尝试通过终端启动 mysql 服务器:
    sudo /usr/local/mysql/support-files/mysql.server start
    返回:
    Starting MySQL
    .. ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
  • 在对这个 pid 文件进行了一些研究之后,我意识到我需要在/etc 中创建 my.cnf,所以我做了..
    cd /usr/local/mysql/support-files/
    sudo cp my-default.cnf /etc/my.cnf
  • 编辑并保存了 my.cnf..
    cd /etc
    sudo nano my.cnf
    , 输入线路
    pid-file = /var/run/mysqld/mysqld.pid
  • 创建目录..

    须藤 mkdir/var/run/mysqld
    须藤触摸/var/run/mysqld/mysqld.pid
    sudo chown -R mysql:mysql/var/run/mysqld
  • 假设 my.cnf 现在应该全部设置,包括 pid 文件。我试图再次启动服务器。然而,一切都没有改变。

  • 好的,那么我决定好了,我会尝试更改安装时临时设置的密码。
  • 我停止了 mysql 服务器(它不应该运行,但以防万一)。 sudo /usr/local/mysql/support-files/mysql.server stop .这可能很有趣,因为我最终处于某种 shell 形式,在这种形式中我无法做任何事情。我必须从这里重新启动终端。
  • 尝试使用 sudo mysql_safe --skip-grant-tables 在安全模式下启动 mysql返回:

    151110 10:28:10 mysqld_safe 登录到“/usr/local/var/mysql/Robs-MacBook-Pro.local.err”。
    151110 10:28:10 mysqld_safe 使用/usr/local/var/mysql 中的数据库启动 mysqld 守护进程
    151110 10:28:10 来自 pid 文件的 mysqld_safe mysqld/usr/local/var/mysql/Robs-MacBook-Pro.local.pid 结束

  • 所以这又是关于这个pid文件的。我在这里没有为basedir/datadir/port/server_id/socket设置值..也许就是这样?如果是这样,我应该在这里设置什么值?

    当我在互联网上摆弄不同的建议时经常出现的其他错误包括:
    Access denied for user root@localhost using password: yes/no
    或者
    Cant connect to mysql server through socket ..
    /usr/local/var/mysql/data/mysqld.local.err最后几行:
    2015-11-17T08:13:55.755115Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2015-11-17T08:13:55.756291Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
    2015-11-17T08:13:55.756310Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
    2015-11-17T08:13:55.780792Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
    2015-11-17T08:13:55.781750Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.9) starting as process 94 ...
    2015-11-17T08:13:55.796438Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
    2015-11-17T08:13:55.802783Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2015-11-17T08:13:55.802816Z 0 [Note] InnoDB: Uses event mutexes
    2015-11-17T08:13:55.802826Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
    2015-11-17T08:13:55.802834Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2015-11-17T08:13:55.804723Z 0 [Note] InnoDB: Number of pools: 1
    2015-11-17T08:13:55.808009Z 0 [Note] InnoDB: Using CPU crc32 instructions
    2015-11-17T08:13:55.821713Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
    2015-11-17T08:13:55.843514Z 0 [Note] InnoDB: Completed initialization of buffer pool
    2015-11-17T08:13:55.898365Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
    2015-11-17T08:13:55.935027Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
    2015-11-17T08:13:55.935222Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
    2015-11-17T08:13:55.950640Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
    2015-11-17T08:13:55.952035Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
    2015-11-17T08:13:55.952061Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
    2015-11-17T08:13:55.952538Z 0 [Note] InnoDB: Waiting for purge to start
    2015-11-17T08:13:56.070486Z 0 [Note] InnoDB: 5.7.9 started; log sequence number 2471474
    2015-11-17T08:13:56.070792Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql-5.7.9-osx10.9-x86_64/data/ib_buffer_pool
    2015-11-17T08:13:56.071268Z 0 [Note] InnoDB: not started
    2015-11-17T08:13:56.072953Z 0 [Note] Plugin 'FEDERATED' is disabled.
    2015-11-17T08:13:56.075825Z 0 [Note] InnoDB: Buffer pool(s) load completed at 151117 9:13:56
    2015-11-17T08:13:56.086709Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
    2015-11-17T08:13:56.112666Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
    2015-11-17T08:13:56.112759Z 0 [Note] IPv6 is available.
    2015-11-17T08:13:56.112804Z 0 [Note] - '::' resolves to '::';
    2015-11-17T08:13:56.113081Z 0 [Note] Server socket created on IP: '::'.
    2015-11-17T08:13:56.180223Z 0 [Note] Event Scheduler: Loaded 0 events
    2015-11-17T08:13:56.180406Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
    Version: '5.7.9' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)

    来自 Vasfed 的一个很好的建议的结果:
    然后,按照说明创建 txt 文件。使用我使用的目录和文件名输入命令: mysqld_safe --init-file=/home/mysql-init &返回: Robs-MacBook-Pro:home leroyklotz$ 151118 09:25:23 mysqld_safe Logging to '/usr/local/var/mysql/Robs-MacBook-Pro.local.err'.
    151118 09:25:23 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
    /usr/local/bin/mysqld_safe: line 129: /usr/local/var/mysql/Robs-MacBook-Pro.local.err: Permission denied
    rm: /tmp/mysql.sock: Permission denied
    /usr/local/bin/mysqld_safe: line 166: /usr/local/var/mysql/Robs-MacBook-Pro.local.err: Permission denied
    151118 09:25:23 mysqld_safe mysqld from pid file /usr/local/var/mysql/Robs-MacBook-Pro.local.pid ended
    /usr/local/bin/mysqld_safe: line 129: /usr/local/var/mysql/Robs-MacBook-Pro.local.err: Permission denied

    授予 Robs-MacBook-Pro.local.err 和 mysql.sock(仍称为 mysql.sock.lock,这有关系吗?)的权限并没有完全解决问题,错误消息现在显示为:
    Robs-MacBook-Pro:~ leroyklotz$ mysqld_safe --init-file=/home/mysql-init &
    [1] 747
    Robs-MacBook-Pro:~ leroyklotz$ 151119 09:13:51 mysqld_safe Logging to '/usr/local/var/mysql/Robs-MacBook-Pro.local.err'.
    151119 09:13:51 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
    rm: /tmp/mysql.sock: Permission denied
    151119 09:13:53 mysqld_safe mysqld from pid file /usr/local/var/mysql/Robs-MacBook-Pro.local.pid ended

    最佳答案

    不要自己创建/触摸 pid 文件,它是由守护进程自己创建的,以指示其 pid

    在 macos 上 mysql 应该可以在没有 my.cnf 的情况下正常运行

    首先是查看 mysqld 日志 /usr/local/var/mysql/Robs-MacBook-Pro.local.err .

    奇怪的位置,顺便说一句,默认在/usr/local/mysql/data/<your_hostname>.err (需要 sudo 才能阅读),可能是您安装的服务器根本没有启动并且您正在运行其他守护程序(例如通过自制软件安装)

    查询 ps ax | grep mysql | grep -v grep - 它应该有 2 个进程,都在 /usr/local/mysql/bin 中带有二进制文件, 如果还有其他 mysql - 这说明了一切

    关于Mysql 连接到服务器 : Access denied for user root@localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33497340/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com