Connecting to mysql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Manzoorul  Hassan

    Connecting to mysql

    I am not able to connect to the mysql DB if I am not the root user. I
    have already found identified an issue:

    * mysql.sock is NOT located in /tmp

    So, to get around it I created a sym link to the actual location
    (/var/lib/mysql/mysql.sock). This file, and the sym link, are both
    owned by root but they have full permission for all user. But the
    parent directories are ONLY READ and EXECUTABLE for non root users.

    If I change the permissions on:

    * /var
    * /var/lib
    * /var/lib/mysql

    I am able to connect to mysql (from both command line and my PHP
    script). But I really don't want to leave it so open.

    Any ideas how to get around this? I'm thinking the best solution would
    be to make mysql create the .sock file in /tmp so that I don't have to
    create the sym link. But I an open for any / all suggestions.

    TIA.

    - manzoor

  • Aggro

    #2
    Re: Connecting to mysql

    Manzoorul Hassan wrote:
    [color=blue]
    > I am able to connect to mysql (from both command line and my PHP
    > script). But I really don't want to leave it so open.[/color]

    I have the sock file un /var/run/mysqld folder, but my permissions are
    these:

    /var/ drwxr-xr-x 15 root root
    /var/lib/ drwxr-xr-x 42 root root
    /var/lib/mysql drwxr-xr-x 20 mysql mysql

    /var/run/ drwxr-xr-x 17 root root
    /var/run/mysqld/ drwxr-xr-x 2 mysql root
    /var/run/mysqld/mysqld.sock srwxrwxrwx 1 mysql mysql

    Don't know if mysql.sock needs that much permissions, but at least the
    /var, /var/run and /var/lib should be ownled and be writable my root
    only. Note that even when only root can write to parent directories, you
    can set other permissions to child directories, as I have.


    One thing I don't understand is how do you people install the MySQL
    server. I just run (Both on Ubuntu and on Debian)

    apt-get update
    apt-get install mysql-server

    And it created the sock-file to correct place, set all permissions to
    files etc. I didn't need to do anything for it. Are there still some
    distros left that don't do this automatically?

    Comment

    • Bill Karwin

      #3
      Re: Connecting to mysql

      Manzoorul Hassan wrote:[color=blue]
      > I am not able to connect to the mysql DB if I am not the root user. I
      > have already found identified an issue:
      >
      > * mysql.sock is NOT located in /tmp[/color]

      I would recommend either specifying the location of the socket file with
      the "mysql -S" option (see
      http://dev.mysql.com/doc/mysql/en/my...-options.html), or else
      you can make an entry in the /etc/my.cnf to make client apps look for
      the socket in another location (see example of [client] options in this
      file at http://dev.mysql.com/doc/mysql/en/option-files.html).

      You can also make the mysqld server create the socket in another
      location like /tmp on startup, also using the option file.

      Also see http://dev.mysql.com/doc/mysql/en/pr...ysql-sock.html

      Regards,
      Bill K.

      Comment

      • Manzoorul  Hassan

        #4
        Re: Connecting to mysql


        Aggro wrote:[color=blue]
        > Manzoorul Hassan wrote:
        >[color=green]
        > > I am able to connect to mysql (from both command line and my PHP
        > > script). But I really don't want to leave it so open.[/color]
        >
        > I have the sock file un /var/run/mysqld folder, but my permissions are
        > these:
        >
        > /var/ drwxr-xr-x 15 root root
        > /var/lib/ drwxr-xr-x 42 root root
        > /var/lib/mysql drwxr-xr-x 20 mysql mysql
        >
        > /var/run/ drwxr-xr-x 17 root root
        > /var/run/mysqld/ drwxr-xr-x 2 mysql root
        > /var/run/mysqld/mysqld.sock srwxrwxrwx 1 mysql mysql
        >
        > Don't know if mysql.sock needs that much permissions, but at least the
        > /var, /var/run and /var/lib should be ownled and be writable my root
        > only. Note that even when only root can write to parent directories, you
        > can set other permissions to child directories, as I have.
        >[/color]

        thanx.
        [color=blue]
        >
        > One thing I don't understand is how do you people install the MySQL
        > server. I just run (Both on Ubuntu and on Debian)
        >
        > apt-get update
        > apt-get install mysql-server
        >
        > And it created the sock-file to correct place, set all permissions to
        > files etc. I didn't need to do anything for it. Are there still some
        > distros left that don't do this automatically?[/color]

        I am installing v4.1.14 (I got it at
        http://dev.mysql.com/downloads/mysql/4.1.html) on Fedora Core 3
        Installation. So I had to first run the configuraion, then "make" and
        "make install".

        - manzoor

        Comment

        • Aggro

          #5
          Re: Connecting to mysql

          Manzoorul Hassan wrote:
          [color=blue]
          > I am installing v4.1.14 (I got it at
          > http://dev.mysql.com/downloads/mysql/4.1.html) on Fedora Core 3
          > Installation. So I had to first run the configuraion, then "make" and
          > "make install".[/color]

          Why don't you just use Fedora package manager to install it for you,
          instead of downloading it and maintaining the upgrades manually? Or does
          it now have version 4.1 which you need?

          Comment

          Working...