在centos7上mysql安装初始化失败

时间:2021-03-18 03:42:35

标签: mysql

我正在尝试在我的 Centos7 虚拟机上安装 Mysql Community Server version5.6.40。

在安装过程中我遇到了以下问题:

1)

[root@Mysql_Server scripts]# ./mysql_install_db.sh --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
-bash: ./mysql_install_db.sh: Permission denied

[root@Mysql_Server support-files]# /etc/init.d/mysqld start
-bash: /etc/init.d/mysqld: Permission denied

我已经使用 chmod a+x 文件名来分配执行权限,但我只想知道为什么这些文件缺少执行权限。 //我下载mysql安装tar文件并用root权限解压

2) 在我运行 mysql_install_db.sh 时

[root@Mysql_Server scripts]# ./mysql_install_db.sh --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

FATAL ERROR: Could not find my_print_defaults

The following directories were searched:

    /application/mysql/bin
    /application/mysql/extra

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.

我尝试按照步骤找出导致此问题的可能原因:

find / my_print_defaults 

find: ‘my_print_defaults’: No such file or directory

ls /application/mysql/


[root@Mysql_Server scripts]# ls /application/mysql/
BUILD            dbug                 libmysqld    README      support-files
client           Docs                 libservices  regex       tests
cmake            Doxyfile-perfschema  man          scripts     unittest
CMakeLists.txt   extra                mysql-test   sql         VERSION
cmd-line-utils   include              mysys        sql-bench   vio
config.h.cmake   INSTALL              mysys_ssl    sql-common  win
configure.cmake  libevent             packaging    storage     zlib
COPYING          libmysql             plugin       strings

没有创建 bin 和额外的目录。

所以我想知道是不是因为我的 centos7 安装选择了最小安装而缺少 gcc gcc-c++ 造成的。

也可能是因为缺少执行权限导致shell文件运行正常。

附:下面的整个操作,以便更好地解决问题

[root@Mysql_Server ~]# yum install wget -y      
[root@Mysql_Server ~]# wget https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.40.tar.gz  
[root@Mysql_Server ~]# tar -xf mysql-5.6.40.tar.gz 
[root@Mysql_Server ~]# mkdir /application   
[root@Mysql_Server ~]# mv mysql-5.6.40 /application/    
[root@Mysql_Server ~]# ln -s /application/mysql-5.6.40/ /application/mysql      
[root@Mysql_Server ~]# cd /application/mysql/support-files/ 
[root@Mysql_Server support-files]# cp my-default.cnf.sh /etc/my.cnf         
[root@Mysql_Server support-files]# cp mysql.server.sh /etc/init.d/mysqld              
[root@Mysql_Server support-files]# cd /application/mysql/scripts/       
[root@Mysql_Server scripts]# useradd mysql -s /sbin/nologin -M      
[root@Mysql_Server scripts]# chmod a+x mysql_install_db.sh
[root@Mysql_Server scripts]# ./mysql_install_db.sh --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

1 个答案:

答案 0 :(得分:0)

源代码和二进制包之间的误解是致命的错误。

由于我下载了源代码,没有编码和打包就不能直接运行。

再次感谢@danblack 的提醒!

我现在已经在 centos7 上成功运行了 mysql_community_server。(使用安装的二进制包)。

现在我要使用源代码安装mysql。

相关问题