Search code examples
mysqllinux

I have some trouble installing mysql on centos7


enter image description here The command I used is mysqld --initialize, but it reports an error saying that the command does not exist. How can I solve this problem?

Since I am a beginner, I am not familiar with Linux and MySQL, so I may have some omissions in some operations. I hope that all the experts can help me to tell me how to solve this problem. Because I have a data competition at the beginning of the school, if I stop at MySQL, I will not be able to continue to operate hive behind it.Please help, thanks.


Solution

  • "the command does not exist" is a generic error when your shell can't find the command.

    You need to do a couple of things:

    Figure out which folder on the machine contains the mysqld binary. You can do that by running this command:

    find / -name mysqld
    

    That will search all folders on the machine for the binary. If it doesn't find it, that means you need to install MySQL from the internet.

    Depending on how your box is set up, youu might be able to install with:

    yum install mysql
    

    Then you need to make sure the folder that contains mysqld is in your PATH. What is PATH? It's a list of folders your shell looks for programs in. You can see what's in your PATH with:

    echo $PATH | tr ':' '\n'
    

    If you don't see the folder, you can add it with:

    export PATH="/path/mysqld:$PATH"
    

    A couple of unrelated notes:

    • CentOS 7 is not supported anymore. Consider upgrading to a supported Linux distribution (CentOS Stream for example).
    • Your screenshot looks like you're using a root shell. Consider using a user shell and using sudo when you need to do root commands.
    • You said you're new to Linux and MySQL. Welcome!!!