MySql/MariaDB cannot change default datadir on Debian 9.1 servermysql cannot start because of init.d...

Ethernet cable only works in certain positions

Which was the first story to feature space elevators?

Does the phrase がんばする makes sense?

GPL - Is it required to post source code to the Public - when is a software released?

Why does calling Python's 'magic method' not do type conversion like it would for the corresponding operator?

Who, if anyone, was the first astronaut to return to earth in a different vessel?

Copy the content of an environment

How to write pow math?

Why is it a problem for Freddie if the guys from Munich did what he wanted?

How should I ship cards?

How can a kingdom keep the secret of a missing monarchy from the public?

Father gets chickenpox, but doesn't infect his two children. How is this possible?

Bitcoin automatically diverted to bech32 address

Manager has noticed coworker's excessive breaks. Should I warn him?

Negotiating 1-year delay to my Assistant Professor Offer

Discouraging missile alpha strikes

How to announce in an ATIS message that two parallel runways are in use?

Why did Shae (falsely) implicate Sansa?

Apparently I’m calling random numbers but nothing in call log?

Identical projects by students at two different colleges: still plagiarism?

How to not forget my phone in the bathroom?

Coworker is trying to get me to sign his petition to run for office. How to decline politely?

Why do climate experts from the UN/IPCC rarely mention Grand Solar Minimum?

Is a particular string regular (e.g is '010') regular?



MySql/MariaDB cannot change default datadir on Debian 9.1 server


mysql cannot start because of init.d folder?How to change data location on UbuntuRecover an Innodb mysql database from an EBS on Ec2MySQL ran out of space, now won't startMoving datadir OK start, but socket error for mysql clientMySQL does not start - Ubuntu 14.04 LTS after migration to new diskHow do I move a MySQL data directory to an external hard drive?How do I get mysql to start for the first time?How to log into a fresh mariaDB install?













3















I have a problem to move the default datadir of Maria DB to another partition, it appears to be very common but i tried everything I can without luck.



Mysql is installed as Mariadb 10.1.26 with the default debian package (apt-get install mysql-server) on a Debian 9.1 (stretch) server, mysqld -v returns mysqld 10.1.26-MariaDB-0+deb9u1



Default_mysql_datadir : /var/lib/mysql



New_mysql_datadir : /home/mysql



/var/lib/mysql is mounted to "/" (/dev/md3)



/home/mysql is mounted to "/home" (/dev/md4)



What I've tried



# systemctl stop mysql
# mv /var/lib/mysql /home


Change datadir in /etc/mysql/my.cnf



datadir = /home/mysql


Check if the rights/permissions are ok



# chown -R mysql.mysql /home/mysql



apparmor is NOT installed nor running on the system though the /etc/apparmor.d/usr.sbin.mysqld file is existing with the following rules :



/home/mysql/ r,
/home/mysql/** rwk,


I even tried to create and empty /var/lib/mysq folder refering to this bug



But when I start I always get the same error :



# systemctl start mysql
[Warning] Can't create test file /home/mysql/<user>.lower-test
#007/usr/sbin/mysqld: Can't change dir to '/home/mysql/' (Errcode: 13 "Permission denied") 2017-09-07 0:16:59 140119808397888 [ERROR] Aborting
mariadb.service: Main process exited, code=exited, status=1/FAILURE
Failed to start MariaDB database server.
mariadb.service: Unit entered failed state.
mariadb.service: Failed with result 'exit-code'.


Any suggestion ?



Thanks










share|improve this question





























    3















    I have a problem to move the default datadir of Maria DB to another partition, it appears to be very common but i tried everything I can without luck.



    Mysql is installed as Mariadb 10.1.26 with the default debian package (apt-get install mysql-server) on a Debian 9.1 (stretch) server, mysqld -v returns mysqld 10.1.26-MariaDB-0+deb9u1



    Default_mysql_datadir : /var/lib/mysql



    New_mysql_datadir : /home/mysql



    /var/lib/mysql is mounted to "/" (/dev/md3)



    /home/mysql is mounted to "/home" (/dev/md4)



    What I've tried



    # systemctl stop mysql
    # mv /var/lib/mysql /home


    Change datadir in /etc/mysql/my.cnf



    datadir = /home/mysql


    Check if the rights/permissions are ok



    # chown -R mysql.mysql /home/mysql



    apparmor is NOT installed nor running on the system though the /etc/apparmor.d/usr.sbin.mysqld file is existing with the following rules :



    /home/mysql/ r,
    /home/mysql/** rwk,


    I even tried to create and empty /var/lib/mysq folder refering to this bug



    But when I start I always get the same error :



    # systemctl start mysql
    [Warning] Can't create test file /home/mysql/<user>.lower-test
    #007/usr/sbin/mysqld: Can't change dir to '/home/mysql/' (Errcode: 13 "Permission denied") 2017-09-07 0:16:59 140119808397888 [ERROR] Aborting
    mariadb.service: Main process exited, code=exited, status=1/FAILURE
    Failed to start MariaDB database server.
    mariadb.service: Unit entered failed state.
    mariadb.service: Failed with result 'exit-code'.


    Any suggestion ?



    Thanks










    share|improve this question



























      3












      3








      3








      I have a problem to move the default datadir of Maria DB to another partition, it appears to be very common but i tried everything I can without luck.



      Mysql is installed as Mariadb 10.1.26 with the default debian package (apt-get install mysql-server) on a Debian 9.1 (stretch) server, mysqld -v returns mysqld 10.1.26-MariaDB-0+deb9u1



      Default_mysql_datadir : /var/lib/mysql



      New_mysql_datadir : /home/mysql



      /var/lib/mysql is mounted to "/" (/dev/md3)



      /home/mysql is mounted to "/home" (/dev/md4)



      What I've tried



      # systemctl stop mysql
      # mv /var/lib/mysql /home


      Change datadir in /etc/mysql/my.cnf



      datadir = /home/mysql


      Check if the rights/permissions are ok



      # chown -R mysql.mysql /home/mysql



      apparmor is NOT installed nor running on the system though the /etc/apparmor.d/usr.sbin.mysqld file is existing with the following rules :



      /home/mysql/ r,
      /home/mysql/** rwk,


      I even tried to create and empty /var/lib/mysq folder refering to this bug



      But when I start I always get the same error :



      # systemctl start mysql
      [Warning] Can't create test file /home/mysql/<user>.lower-test
      #007/usr/sbin/mysqld: Can't change dir to '/home/mysql/' (Errcode: 13 "Permission denied") 2017-09-07 0:16:59 140119808397888 [ERROR] Aborting
      mariadb.service: Main process exited, code=exited, status=1/FAILURE
      Failed to start MariaDB database server.
      mariadb.service: Unit entered failed state.
      mariadb.service: Failed with result 'exit-code'.


      Any suggestion ?



      Thanks










      share|improve this question
















      I have a problem to move the default datadir of Maria DB to another partition, it appears to be very common but i tried everything I can without luck.



      Mysql is installed as Mariadb 10.1.26 with the default debian package (apt-get install mysql-server) on a Debian 9.1 (stretch) server, mysqld -v returns mysqld 10.1.26-MariaDB-0+deb9u1



      Default_mysql_datadir : /var/lib/mysql



      New_mysql_datadir : /home/mysql



      /var/lib/mysql is mounted to "/" (/dev/md3)



      /home/mysql is mounted to "/home" (/dev/md4)



      What I've tried



      # systemctl stop mysql
      # mv /var/lib/mysql /home


      Change datadir in /etc/mysql/my.cnf



      datadir = /home/mysql


      Check if the rights/permissions are ok



      # chown -R mysql.mysql /home/mysql



      apparmor is NOT installed nor running on the system though the /etc/apparmor.d/usr.sbin.mysqld file is existing with the following rules :



      /home/mysql/ r,
      /home/mysql/** rwk,


      I even tried to create and empty /var/lib/mysq folder refering to this bug



      But when I start I always get the same error :



      # systemctl start mysql
      [Warning] Can't create test file /home/mysql/<user>.lower-test
      #007/usr/sbin/mysqld: Can't change dir to '/home/mysql/' (Errcode: 13 "Permission denied") 2017-09-07 0:16:59 140119808397888 [ERROR] Aborting
      mariadb.service: Main process exited, code=exited, status=1/FAILURE
      Failed to start MariaDB database server.
      mariadb.service: Unit entered failed state.
      mariadb.service: Failed with result 'exit-code'.


      Any suggestion ?



      Thanks







      mysql mariadb debian






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 7 '17 at 13:45







      fft

















      asked Sep 7 '17 at 12:09









      fftfft

      1613




      1613






















          2 Answers
          2






          active

          oldest

          votes


















          5














          You must set ProtectHome=false in the systemd config file in order to move your datadir to the /home directory.



          According to Debian policy rules, you should set this option value in a custom file like /etc/systemd/system/mariadb.service.d/YOUR_CUSTOM_FILE.conf containing:



          [Service]

          # Prevent accessing /home, /root and /run/user
          ProtectHome=false


          Then reload systemctl daemon:



          systemctl daemon-reload



          After that you should be able to change MariaDB datadir from /var/lib/mysql to /home/mysql.






          share|improve this answer


























          • We just ran into this after a version upgrade on a production server. We had to add ProtectSystem=false in addition to ProtectHome=false. After adding ProtectHome=false, the error changed to: [ERROR] mysqld: File '/home/mysql/mysql-bin.index' not found (Errcode: 30 "Read-only file system") When it was clearly not actually a read only situation.

            – Jestep
            Feb 7 '18 at 16:04











          • systemd documentation for mariadb contains this an other tips. Needing ProtectSystem=false seems odd. Did you miss running daemon-reload maybe?

            – danblack
            1 hour ago



















          0














          I regret I do not have the reputation to upvote the [Nicolas Payart] answer.



          This whitelist in /etc/systemd/mariadb.service.d/whatever.conf:



          [Service]
          ReadWritePaths=/home/mysql


          may be another solution, but I would not have found it without Mr. Payart's wisdom.






          share|improve this answer










          New contributor




          Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "182"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f185302%2fmysql-mariadb-cannot-change-default-datadir-on-debian-9-1-server%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            You must set ProtectHome=false in the systemd config file in order to move your datadir to the /home directory.



            According to Debian policy rules, you should set this option value in a custom file like /etc/systemd/system/mariadb.service.d/YOUR_CUSTOM_FILE.conf containing:



            [Service]

            # Prevent accessing /home, /root and /run/user
            ProtectHome=false


            Then reload systemctl daemon:



            systemctl daemon-reload



            After that you should be able to change MariaDB datadir from /var/lib/mysql to /home/mysql.






            share|improve this answer


























            • We just ran into this after a version upgrade on a production server. We had to add ProtectSystem=false in addition to ProtectHome=false. After adding ProtectHome=false, the error changed to: [ERROR] mysqld: File '/home/mysql/mysql-bin.index' not found (Errcode: 30 "Read-only file system") When it was clearly not actually a read only situation.

              – Jestep
              Feb 7 '18 at 16:04











            • systemd documentation for mariadb contains this an other tips. Needing ProtectSystem=false seems odd. Did you miss running daemon-reload maybe?

              – danblack
              1 hour ago
















            5














            You must set ProtectHome=false in the systemd config file in order to move your datadir to the /home directory.



            According to Debian policy rules, you should set this option value in a custom file like /etc/systemd/system/mariadb.service.d/YOUR_CUSTOM_FILE.conf containing:



            [Service]

            # Prevent accessing /home, /root and /run/user
            ProtectHome=false


            Then reload systemctl daemon:



            systemctl daemon-reload



            After that you should be able to change MariaDB datadir from /var/lib/mysql to /home/mysql.






            share|improve this answer


























            • We just ran into this after a version upgrade on a production server. We had to add ProtectSystem=false in addition to ProtectHome=false. After adding ProtectHome=false, the error changed to: [ERROR] mysqld: File '/home/mysql/mysql-bin.index' not found (Errcode: 30 "Read-only file system") When it was clearly not actually a read only situation.

              – Jestep
              Feb 7 '18 at 16:04











            • systemd documentation for mariadb contains this an other tips. Needing ProtectSystem=false seems odd. Did you miss running daemon-reload maybe?

              – danblack
              1 hour ago














            5












            5








            5







            You must set ProtectHome=false in the systemd config file in order to move your datadir to the /home directory.



            According to Debian policy rules, you should set this option value in a custom file like /etc/systemd/system/mariadb.service.d/YOUR_CUSTOM_FILE.conf containing:



            [Service]

            # Prevent accessing /home, /root and /run/user
            ProtectHome=false


            Then reload systemctl daemon:



            systemctl daemon-reload



            After that you should be able to change MariaDB datadir from /var/lib/mysql to /home/mysql.






            share|improve this answer















            You must set ProtectHome=false in the systemd config file in order to move your datadir to the /home directory.



            According to Debian policy rules, you should set this option value in a custom file like /etc/systemd/system/mariadb.service.d/YOUR_CUSTOM_FILE.conf containing:



            [Service]

            # Prevent accessing /home, /root and /run/user
            ProtectHome=false


            Then reload systemctl daemon:



            systemctl daemon-reload



            After that you should be able to change MariaDB datadir from /var/lib/mysql to /home/mysql.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 29 '17 at 8:58

























            answered Nov 17 '17 at 16:55









            Nicolas PayartNicolas Payart

            69531127




            69531127













            • We just ran into this after a version upgrade on a production server. We had to add ProtectSystem=false in addition to ProtectHome=false. After adding ProtectHome=false, the error changed to: [ERROR] mysqld: File '/home/mysql/mysql-bin.index' not found (Errcode: 30 "Read-only file system") When it was clearly not actually a read only situation.

              – Jestep
              Feb 7 '18 at 16:04











            • systemd documentation for mariadb contains this an other tips. Needing ProtectSystem=false seems odd. Did you miss running daemon-reload maybe?

              – danblack
              1 hour ago



















            • We just ran into this after a version upgrade on a production server. We had to add ProtectSystem=false in addition to ProtectHome=false. After adding ProtectHome=false, the error changed to: [ERROR] mysqld: File '/home/mysql/mysql-bin.index' not found (Errcode: 30 "Read-only file system") When it was clearly not actually a read only situation.

              – Jestep
              Feb 7 '18 at 16:04











            • systemd documentation for mariadb contains this an other tips. Needing ProtectSystem=false seems odd. Did you miss running daemon-reload maybe?

              – danblack
              1 hour ago

















            We just ran into this after a version upgrade on a production server. We had to add ProtectSystem=false in addition to ProtectHome=false. After adding ProtectHome=false, the error changed to: [ERROR] mysqld: File '/home/mysql/mysql-bin.index' not found (Errcode: 30 "Read-only file system") When it was clearly not actually a read only situation.

            – Jestep
            Feb 7 '18 at 16:04





            We just ran into this after a version upgrade on a production server. We had to add ProtectSystem=false in addition to ProtectHome=false. After adding ProtectHome=false, the error changed to: [ERROR] mysqld: File '/home/mysql/mysql-bin.index' not found (Errcode: 30 "Read-only file system") When it was clearly not actually a read only situation.

            – Jestep
            Feb 7 '18 at 16:04













            systemd documentation for mariadb contains this an other tips. Needing ProtectSystem=false seems odd. Did you miss running daemon-reload maybe?

            – danblack
            1 hour ago





            systemd documentation for mariadb contains this an other tips. Needing ProtectSystem=false seems odd. Did you miss running daemon-reload maybe?

            – danblack
            1 hour ago













            0














            I regret I do not have the reputation to upvote the [Nicolas Payart] answer.



            This whitelist in /etc/systemd/mariadb.service.d/whatever.conf:



            [Service]
            ReadWritePaths=/home/mysql


            may be another solution, but I would not have found it without Mr. Payart's wisdom.






            share|improve this answer










            New contributor




            Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

























              0














              I regret I do not have the reputation to upvote the [Nicolas Payart] answer.



              This whitelist in /etc/systemd/mariadb.service.d/whatever.conf:



              [Service]
              ReadWritePaths=/home/mysql


              may be another solution, but I would not have found it without Mr. Payart's wisdom.






              share|improve this answer










              New contributor




              Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.























                0












                0








                0







                I regret I do not have the reputation to upvote the [Nicolas Payart] answer.



                This whitelist in /etc/systemd/mariadb.service.d/whatever.conf:



                [Service]
                ReadWritePaths=/home/mysql


                may be another solution, but I would not have found it without Mr. Payart's wisdom.






                share|improve this answer










                New contributor




                Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                I regret I do not have the reputation to upvote the [Nicolas Payart] answer.



                This whitelist in /etc/systemd/mariadb.service.d/whatever.conf:



                [Service]
                ReadWritePaths=/home/mysql


                may be another solution, but I would not have found it without Mr. Payart's wisdom.







                share|improve this answer










                New contributor




                Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer








                edited 1 hour ago









                Erik Darling

                21.2k1265105




                21.2k1265105






                New contributor




                Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 1 hour ago









                Brian CarcichBrian Carcich

                1




                1




                New contributor




                Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Brian Carcich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f185302%2fmysql-mariadb-cannot-change-default-datadir-on-debian-9-1-server%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Parapolítica Índice Antecedentes El escándalo Proceso judicial Consecuencias Véase...

                    How to remove border from elements in the last row?Targeting flex items on the last rowHow to vertically wrap...

                    Tecnologías entrañables Índice Antecedentes Desarrollo Tecnologías Entrañables en la...