Home  >  Q&A  >  body text

centos环境,mysql可以用非root(普通用户)安装么?

centos6.8i386,mysql5.7.17,看mysql的文档好像只有使用root权限安装。

可是这样不是不符合安全原则么?还是说所谓安全,只要是非root用户启动就好,安装的话是root还是非root都无所谓?

那么有非root用户编译安装mysql的教程么?我当然在网上搜到了很多,可是都不能成功,或者无法初始化。还有一些自己对cmake时编译的宏命令理解错误,参数对照文档也是过时的。

所以,一般企业,或者说按照管理的安全准则,mysql应该怎么安装?以及,究竟怎么用非root安装编译mysql?

PHP中文网PHP中文网2714 days ago828

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 16:36:44

    You don’t need root to compile.
    It’s not impossible to install. It’s just that many of the default directories of MySQL have write permissions only for administrators. So it can only be installed with administrator privileges.
    If you install it yourself, you can install it in your own directory. I have not tried it, but there may be a write path in the source code that you need to set manually.

    Regarding the installation guidelines, you can install it with root, and you can run it with other permissions when running.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 16:36:44

    The reason why root installation is required is because the default installation requires writing some files (such as the executable file mysql, etc.) to some important directories (such as /usr/xxx, /usr/local/, /bin/, /etc/, etc.) Mysqld is written to the bin folder, dependent files are written to the lib folder, and the configuration file my.cnf is written to /etc/)

    Then as long as you configure the installation directory (./configure --prefix installation path) in your user directory, you don’t need root permissions. But to run it after installation, go to the bin folder of the installation directory to find the executable file and execute it. Okay, please note that you may need to specify the location of the configuration file when executing (the default is /etc/, but since you don’t install with root, it is naturally not there, but it defaults to that place to find the configuration file)

    As for why you need root installation? Naturally, it is to share resources and save space. Otherwise, only you and the root user can use it and other users will not be able to use it.

    As for why you need to start with root? Because after the program is started, it will generate some messy files (such as logs, data files) in its own installation directory. If your installation directory is root, all of them will naturally need to be run by root to write.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 16:36:44

    Let’s talk about the use of mysql
    DBA can only operate the mysql database, not the log files
    Operation and maintenance can move the log files, but not the mysql database

    I will add more when I have time

    reply
    0
  • Cancelreply