欢迎投稿

今日深度:

MySQL报错:StartingMySQLERROR!Couldn‘tfindMySQLserver(/usr/local/mysql/bin/mysqld_safe),

MySQL报错:StartingMySQLERROR!Couldn‘tfindMySQLserver(/usr/local/mysql/bin/mysqld_safe),


1. 要对MySQL数据库清除原来已有的数据,重新初始化数据库。

Linux系统:CentOS7.6,数据库:MySQL5.6.40。先将mysql进程强行停止掉。

pkill mysqld

2. 对数据库进行清理:

[root@mv172 ~]# rm -rf /application/mysql/data/*
[root@mv172 ~]# \rm -rf /data/mysql/*

3. 配置文件安装在/application/mysql-5.6.40/my.cnf

[mysqld]
basedir=/application/mysql
datadir=/application/mysql/data
socket=/tmp/mysql.sock
log_error=/var/log/mysql.log
log_bin=/data/mysql/mysql-bin
binlog_format=row
skip-name-resolve
server_id=172
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
[client]
socket=/tmp/mysql.sock

4. 执行数据库初始化命令: 这次初始化没有把配置文件添加进去,导致问题的开始。

[root@mv172 ~]# /application/mysql/scripts/mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/

......出现一堆的执行代码,此处就省略:

5.  将mysql启动复制到系统为默认启动路径

[root@mv172 ~]# \cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld

6. # 启动mysql,这时候有报错:

[root@mv172 ~]# /etc/init.d/mysqld start
/etc/init.d/mysqld: line 244: my_print_defaults: command not found
/etc/init.d/mysqld: line 264: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

7. 经过不断尝试,终于找到问题根源。 因为起初 初始化时,没有将mysql路径和数据库保存路径绑定好,而导致一连串问题。

查配置文件,没有配置的保存mysql-bin二进制保存路径。

[root@mv172 /]# mkdir -p /data/mysql
[root@mv172 /]# chown -R mysql.mysql /data/*

8. 重新初始化数据,自此增加“--defaults-file=/application/mysql/my.cnf”

[root@mv172 data]# /application/mysql/scripts/mysql_install_db --defaults-file=/application/mysql/my.cnf --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

9 . # 于是查看mysqld文件
发现
“basedir=
datadir=”
这两个路径,突然想到mysql启动顺手时以这个mysqld优先,于是将配置文件这两个路径添加到这里来,

#   [mysqld]
#   basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
#   below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.


basedir=
datadir=

......

10 . 重新再执行初始化数据库,执行

启动数据库命令

[root@mv172 data]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!

到此这篇关于MySQL报错:Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)的文章就介绍到这了,更多相关Starting MySQL ERROR!内容请搜索PHP之友以前的文章或继续浏览下面的相关文章希望大家以后多多支持PHP之友! 

您可能感兴趣的文章:
  • 解决springboot项目启动报错Error creating bean with name dataSourceScriptDatabaseInitializer问题
  • SpringBoot启动报错Whitelabel Error Page: This application has no explicit mapping for的解决方法
  • 解决修复报错Error in render:TypeError:Cannot read properties of undefined(reading ‘ipconfig‘)问题
  • 解决ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many问题

www.htsjk.Com true http://www.htsjk.com/Mysql/47828.html NewsArticle MySQL报错:StartingMySQLERROR!Couldn‘tfindMySQLserver(/usr/local/mysql/bin/mysqld_safe), 1. 要对MySQL数据库清除原来已有的数据,重新初始化数据库。 Linux系统:CentOS7.6,数据库:MySQL5.6.40。先将mysql进...
评论暂时关闭