mac mysql更改了目录所遇到的坑

    技术2022-07-11  123

    之前安装的目录为/usr/local/develope/mysql

    后来改了下目录 同时也改了MySQL文件夹名

    现在为/usr/local/develope/develop/mysql5.6 同时data目录还是在的

    配置文件已经修改 

    MySQL在安装或者启动的时候没有指定配置文件时候 默认找的配置文件/etc/my.cnf

    将basedir目录和data目录修改为新的目录(注意一定要修改对 )

    basedir=/usr/local/develop/mysql5.6 datadir=/usr/local/develop/mysql5.6/data

     

    误区 修改了目录后不需要重新初始化 因为data目录是不为空的  除非删除掉data目录 重新安装 

    错误1:无法解析的域名

    root@xxx-Pro mysql5.6 # ./scripts/mysql_install_db --user=mysql

    FATAL ERROR: Neither host 'xxx.Pro.local' nor 'localhost' could be looked up with

    /usr/local/develope/mysql5.6/bin/resolveip

    Please configure the 'hostname' command to return a correct

    hostname.

    If you want to solve this at a later stage, restart this script

    with the --force option

    解决方法 编辑 /etc/hosts文件

    127.0.0.1 localhost xxx.Pro.local

    保存退出 即可

    同时在mysql5.6 该目录下 运行 ./bin/resolveip localhost

    IP address of localhost is 127.0.0.1

    出来如下内容即为配置成功

     

    同样还是误区 不需要重新安装 或者考虑删除 data目录 重新安装

    root@xxx-Pro scripts # ./mysql_install_db --user=mysql

    FATAL ERROR: Could not find ./bin/my_print_defaults

     

    If you compiled from source, you need to run 'make install' to

    copy the software into the correct location ready for operation.

     

    If you are using a binary release, you must either be at the top

    level of the extracted archive, or pass the --basedir option

    pointing to that location.

    解决 在scripts 目录下 ./bin/my_print_defaults  这个文件是没有的

    需要在mysql5.6 安装根路径下 进行执行 

     

    错误原因 服务器在没有更新PID文件的情况下退出

    root@xxx-Pro mysql5.6 # ./support-files/mysql.server start

    Starting MySQL

    .Warning: World-writable config file '/usr/local/develop/mysql5.6/my.cnf' is ignored

    Warning: World-writable config file '/usr/local/develop/mysql5.6/my.cnf' is ignored

    Logging to '/usr/local/develop/mysql5.6/data/liangzhuangdeMacBook-Pro.local.err'.

    .. ERROR! The server quit without updating PID file (/usr/local/develop/mysql5.6/data/liangzhuangdeMacBook-Pro.local.pid).

    解决办法 

    1.检查/etc/my.cnf MySQL配置文件的 basedir配置和datadir配置是否修改正确

    basedir=/usr/local/develop/mysql5.6 datadir=/usr/local/develop/mysql5.6/data

    2.如果basedir配置和datadir配置修改的正确 尝试删除 /etc/my.cnf 文件 (注意备份)然后重新启动MySQL

     

     

    Processed: 0.011, SQL: 9