Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to install mySQL on CentOS.

I do not have a root account on that machine.

How can I install mySQL on CentOS as a user, ie. without being root?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

For RPM packages (and CentOS is certainly a RPM system) you need to be root to run the rpm installer. The RPM installer needs to write to some package tracking dbs, and you need to be root to write to them. OK, well, mysql allows you to install from a tarball, right? (http://dev.mysql.com/doc/refman/5.0/en/binary-installation.html). Well, yeah, but there's a postinstall that you'll need to run, that you'll need to be root to do.

RPMs can have pre-and postinstall steps outside of just dumping out files. these can be changing configuration files, adding/deleting users. In general you may need to be root to do these. Even without scripts, you generally install into directories that only root can install to.

In another comment, you mention other packages that you've installed that you didn't need to be root. For these packages I'm sure that:

  • You installed from a tarball, not an RPM.
  • You installed into a non-system dir
  • The code was not tied to any specific dir (some code is compiled for specific paths)
  • There was no postinstall needed (no system config in /etc, no new users like MySQL needs)
share|improve this answer

INSTALLING MYSQL ON CENTOS WITHOUT ROOT ACCOUNT:

  1. Download MySQL Community Server 5.5.8 Linux - Generic Compressed TAR Archive
  2. Unpack it. For example to: /home/martin/mysql
  3. Create my.cnf file in your home directory. The file contents should be:

    [server]
    user=martin
    basedir=/home/martin/mysql
    datadir=/home/martin/sql_data
    socket=/home/martin/socket
    port=3666
    
  4. Go to the /home/martin/mysql directory and execute:

    ./scripts/mysql_install_db --defaults-file=~/my.cnf --user=martin --basedir=/home/martin/mysql --datadir=/home/martin/sql_data --socket=/home/martin/socket
    

    Note that --defaults-file MUST be the first parameter, otherwise it won't work! It's a MySQL bug.

  5. Your MySQL server is ready. Start it with this command:

    ./bin/mysqld_safe --defaults-file=~/my.cnf &
    

    Connecting to server:

    mysql -h 127.0.0.1 -P 3666 -u root -p (using tcp)
    

    or

    mysql --socket=/home/martin/socket -u root -p (using unix socket)
    

    Shutting down server:

    mysqladmin -h 127.0.0.1 -P 3666 -u root shutdown(using tcp)
    

    or

    mysqladmin --socket=/home/martin/socket -u root shutdown (using unix socket)
    
share|improve this answer
    
@gareth After step 5 when I try to connect to server it says mysql commandnot found. can you please tell me why is it like this. I followed the steps exactly. –  vinay Jul 7 '11 at 6:05
    
Hi @vinay - I edited this answer but am not the original author. @martin can you help? –  8088 Jul 7 '11 at 13:19

You can build it and run it from your home directory if you have a compiler available, but in order to install software on linux, you will require root access.

share|improve this answer
    
But I actually have installed plenty of other software already (javac, R) on CentOS without having root access?! –  gojira Nov 10 '10 at 6:21

Martin's answer worked for me. To address the comments (I can't comment due to permissions here):

To connect to the server, you either need to add the /home/martin/mysql/bin directory (/home/martin/mysql/bin in the example) to your path, or use the full path name to run it:

/home/martin/mysql/bin/mysql --socket=/home/martin/socket -u root -p

The other missing piece was setting the root password. After doing the bin/mysqld_safe step (see step 5 in Martin's response), MySql told me how to set the root password. You need to do that step, but adding the --socket=/home/martin/socket option to the command line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.