Results 1 to 9 of 9

Thread: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

  1. #1
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,032

    Default Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Hello.

    Due to the problem cited in the title, I have wrote a script which :

    sudo myscript.sh -->
    1°) Stop the mysql server
    2°) Remove the current mariadb software ( zypper rm everything )
    3°) Remove every files left
    4°) Install mariadb software
    5°) Start the mysql server ( systemctl start mysql.service; a database is created. )
    exit
    Now as normal user :
    Code:
    mysql -u root --> get connected
    Now as root user
    sudo myscript_2.sh -->
    Code:
            systemctl stop mysql.service
    cp -v MY_mysql.cnf /etc/my.cnf
    chmod -v 644 /etc/my.cnf chown -v mysql:mysql /etc/my.cnf systemctl start mysql.service mysql -u root --> ERROR
    Here screen copy
    Code:
    user_install@linux-dpgm:~> systemctl stop mysql
    user_install@linux-dpgm:~> systemctl status mysql
    ● mysql.service - MySQL server
       Loaded: loaded (/usr/lib/systemd/system/mysql.service; disabled; vendor preset: disabled)
       Active: inactive (dead) since ven. 2018-03-09 12:17:16 CET; 3s ago
      Process: 9715 ExecStartPost=/usr/lib/mysql/mysql-systemd-helper wait (code=exited, status=0/SUCCESS)
      Process: 9714 ExecStart=/usr/lib/mysql/mysql-systemd-helper start (code=exited, status=0/SUCCESS)
      Process: 9702 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade (code=exited, status=0/SUCCESS)
      Process: 9691 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install (code=exited, status=0/SUCCESS)
     Main PID: 9714 (code=exited, status=0/SUCCESS)
    user_install@linux-dpgm:~> systemctl start mysql
    user_install@linux-dpgm:~> systemctl status mysql
    ● mysql.service - MySQL server
       Loaded: loaded (/usr/lib/systemd/system/mysql.service; disabled; vendor preset: disabled)
       Active: active (running) since ven. 2018-03-09 12:17:27 CET; 2s ago
      Process: 9919 ExecStartPost=/usr/lib/mysql/mysql-systemd-helper wait (code=exited, status=0/SUCCESS)
      Process: 9906 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade (code=exited, status=0/SUCCESS)
      Process: 9895 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install (code=exited, status=0/SUCCESS)
     Main PID: 9918 (mysqld)
        Tasks: 23 (limit: 512)
       CGroup: /system.slice/mysql.service
               └─9918 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysql
    user_install@linux-dpgm:~> mysql -u root
    mysql: Can't read dir of '/etc/my.cnf.d' (Errcode: 13 "Permission denied")
    Fatal error in defaults handling. Program aborted
    user_install@linux-dpgm:~>
    here is the diff of the two my.cnf
    Code:
    user_install@linux-dpgm:~> /backup_sys/000_COMMON/Bin/files_find_files_show_diff
    user_install@linux-dpgm:~>
    here the diff shell script
    Code:
    # # ensure running as root
    if [ "$(id -u)" != "0" ]; then
        exec sudo "$0" "$@"
    fi
    #
    #
    LEFT_FILE="/etc/my.cnf"
    RIGHT_FILE="/etc/my.cnf.initial.modified.-00-2-2"
    #
    #
    diff -B --side-by-side --text --suppress-common-lines  <(grep -vE '^\s*(#|$)' ${LEFT_FILE})  <(grep -vE '^\s*(#|$)' ${RIGHT_FILE})
    Any help is welcome.
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  2. #2

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Quote Originally Posted by jcdole View Post
    Now as root user
    sudo myscript_2.sh -->
    Code:
            systemctl stop mysql.service
    cp -v MY_mysql.cnf /etc/my.cnf
    chmod -v 644 /etc/my.cnf chown -v mysql:mysql /etc/my.cnf systemctl start mysql.service mysql -u root --> ERROR
    That is wrong.
    The permissions should be:
    Code:
    ls -l /etc/my.cnf
    
    -rw-r----- 1 root mysql 3367 13. Feb 13:27 /etc/my.cnf
    Code:
    user_install@linux-dpgm:~> systemctl start mysql
    You need to run systemctl as root.

    Code:
    user_install@linux-dpgm:~> mysql -u root
    mysql: Can't read dir of '/etc/my.cnf.d' (Errcode: 13 "Permission denied")
    Fatal error in defaults handling. Program aborted
    user_install@linux-dpgm:~>
    Well, it can't access /etc/my.cnf.d/ because you ran the system daemon as unprivileged user.
    The permissions of this directory are:
    Code:
    ls -ld /etc/my.cnf.d
    
    drwxr-x--- 2 root mysql 160 13. Feb 13:26 /etc/my.cnf.d

  3. #3
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,032

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Quote Originally Posted by wolfi323 View Post
    That is wrong.
    The permissions should be:
    Code:
    ls -l /etc/my.cnf
    
    -rw-r----- 1 root mysql 3367 13. Feb 13:27 /etc/my.cnf
    OK. Noted


    Quote Originally Posted by wolfi323 View Post
    You need to run systemctl as root.

    Well, it can't access /etc/my.cnf.d/ because you ran the system daemon as unprivileged user.
    The permissions of this directory are:
    Code:
    ls -ld /etc/my.cnf.d
    
    drwxr-x--- 2 root mysql 160 13. Feb 13:26 /etc/my.cnf.d
    But I am asked the root password as soon as I typed the command ( for start or stop ).

    http://paste.opensuse.org/88712780

    Ok I redo all my test with the correct permission on /etc/my.cnf and give news.
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  4. #4

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Quote Originally Posted by jcdole View Post
    But I am asked the root password as soon as I typed the command ( for start or stop ).
    And does it work if you use sudo e.g., or run systemctl as root in the first place?

    Ok I redo all my test with the correct permission on /etc/my.cnf and give news.
    Well, this will rather not help with accessing /etc/my.cnf.d/ ...
    Last edited by wolfi323; 09-Mar-2018 at 05:27.

  5. #5

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Quote Originally Posted by wolfi323 View Post
    And does it work if you use sudo e.g., or run systemctl as root in the first place?
    Although, it does work fine here if I run "systemctl start mysql" as user (and enter the root password into the dialog that appears)...

    What are the permissions for "/etc/my.cnf.d/" in your case?

    Maybe try to disable AppArmor as a test?
    This might block things if wrongly configured, which leads to strange "permission errors" even if things are run as root.

    Code:
    systemctl stop apparmor

  6. #6
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,273
    Blog Entries
    2

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    From what you posted,
    You seem to be changing permissions on the mysql configuration file which won't do anything at all.
    Database apps in general including mysql/mariadb run in a service account security context which is completely separate from its own database users which again is completely different than system users.

    So, in other words...
    I don't think anything you've done has anything to do with each other, much less the objective stated in your subject line.

    First thing you should do is restore your mariadb install to its default configuration, completely.
    Then you should run the mysql security script which among other things sets the mysqladmin password and whether you you can set up remote connections or not.
    Then, if I understand your objective correctly, create a database
    Then add an additional user other than the mysqladmin to access that database.

    There are no "normal users" as I think you're describing...
    And, "normal users" shouldn't have anything to do with system users.
    Only non-admin database users which have to be created on a database by database basis that don't have mysqladmin privileges which <might> have same credentials as system users.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  7. #7
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,032

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Quote Originally Posted by tsu2 View Post
    From what you posted,
    There are no "normal users" as I think you're describing...
    And, "normal users" shouldn't have anything to do with system users.
    Only non-admin database users which have to be created on a database by database basis that don't have mysqladmin privileges which <might> have same credentials as system users.

    TSU
    "normal users" is any user which is not root.
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  8. #8
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,032

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Quote Originally Posted by wolfi323 View Post
    And does it work if you use sudo e.g., or run systemctl as root in the first place?


    Well, this will rather not help with accessing /etc/my.cnf.d/ ...
    Ok the problem comes from bad permission on /etc/my.cnf as you said.

    Starting/Stoping whith sudo or not as normal user (not root ) make no difference as soon as the permission is set correctly.

    With wrong permission ( mode 644 ) starting/stoping with systemctl in an admin konsole, and login to the mariadb server from normal user (not root) konsole make no difference : that give an error
    Code:
    mysql: Can't read dir of  '/etc/my.cnf.d' (Errcode: 13 "Permission denied")Fatal error in defaults  handling. Program aborted
    .

    Thank you very much.
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  9. #9
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,032

    Default Re: Mariadb - could not connect as normal user after overwriting with a new /etc/my.cnf file

    Thread is solved.

    Thank you every body for helping
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •