Mysql installation - Operation not permitted

Hello,
Since over one week, I have been consistently searching for a solution to my mysql installation errors. I surfed many sites on google to get rid of the issue. Now google gives me all the same results, I tested many of those solutions provided by... Now I am pulling hair

I am under ubuntu16.04 pc. Normally it was installed earlier. Then I faced incompatibility issues between mysql version and the softwares. So, removed mysql with below commands earlier.

sudo apt-get remove --purge mysql-server mysql-common
rm -rf /etc/mysql /var/lib/mysql
apt-get autoremove
apt-get autoclean
apt-get purge mysql*
apt-get -f install
apt-get update

Then I run below command to install mysql with other essential programs in ubuntu 16.04:

sudo apt-get install mysql-server php php-mysql php-pear nodejs libapache2-mod-php

I am receiving below error.

mv: cannot move '/etc/mysql/my.cnf' to '/etc/mysql/my.cnf.dpkg-backup': Operation not permitted
dpkg: error processing archive /var/cache/apt/archives/mysql-common_5.7.25-0ubuntu0.16.04.2_all.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-common_5.7.25-0ubuntu0.16.04.2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

kernel version:

root@pc:~# uname -r
4.9.148-xxxx-std-ipv6-64

If I can not solve this issue, I will have to reinstall ubuntu 16.04 from scratch.
I'd appreciate your recommendation

Kind regards
Boris

This might be just a rights issue. You can't use sudo unless you are authorised to do so.

Have you tried all this logged in as root???????

Root user overrides conventional security and will not be stopped on rights issues.

What userid are you running this installation under?

Hello Hicksd8,
I am root...

Boris

Do you have additional security layers installed, e.g. SELinux? Post the result of ls -la /etc/mysql .

Here you are:

drwxr-xr-x   2 root root  4096 Apr 27 02:23 .
drwxr-xr-x 125 root root 12288 Apr 27 17:36 ..
-rw-r--r--   1 root root  1256 Dec 31 00:27 my.cnf
-rw-r--r--   1 root root   839 Apr 26 03:30 my.cnf.fallback

Thank you
Boris

Boris,

if you are root as you say you are, why are you using sudo ?

Hello Neo,
Normally you are right... Does it make any difference with/without sudo when I am root?
By the way, reinstallation is in progress.
But I'd like to know if you have any idea to fix it so that I'd keep your thought in my pocket for future isssues...

Installation progress
The installation request has been registered.
Copying system ( 4 / 8 )

Thank you
Boris

Boris,

You do not need to use sudo when you are root .

Also, you could have tested easily by manually moving or copying the config file in your original post as root .

Thanks Neo,
I tried sudoedit , gedit etc but none of them worked.
It was saying read only . Also rm command was not responding..
I suppose after upgrading from ubuntu14.04 to 16.04, I broke my repositories and made some non-returnable changes so that the system could not have repaired it. I am not a professeur on linux :confused: You all may guess what could be the solution.

Thank you
Boris

If you are root and cannot perform simple operations like move, copy and edit you need to check your filesystem to insure it is not mounted read only.

1 Like

There is one more thing that could be an issue, denying deletion ever for root.

Check in the working directory with command lsattr /etc/mysql
The former admin perhaps implemented immutable flag with chattr +i <file>

Until that flag is removed with chattr -i <file> , you won't be able to do much with file except reading it.

Very underused and forgotten feature.

Example :

root@hickup:~/example# pwd
/root/example
root@hickup:~/example# printf "%s\n" "some text" > example.conf
root@hickup:~/example# chattr +i example.conf 
root@hickup:~/example# lsattr example.conf 
----i---------e---- example.conf
root@hickup:~/example# rm example.conf 
rm: cannot remove 'example.conf': Operation not permitted
root@hickup:~/example# rm -f example.conf 
rm: cannot remove 'example.conf': Operation not permitted
root@hickup:~/example# printf "%s\n" "Add text" >> example.conf 
-bash: example.conf: Operation not permitted
root@hickup:~/example# mv example.conf example2.conf
mv: cannot move 'example.conf' to 'example2.conf': Operation not permitted

Hope that helps
Regards
Peasant.

1 Like

Before setting with chattr , the OP should probably list first, for example:

lsattr example.conf

The OP said he does not have any experience in Linux, so before going around changing file attributes, he should list them first before he makes even more mistakes.

My first guess is the the file system has been mounted read-only.

:slight_smile:

Thank you Peasant,
I will record this into my notes.

Kind regards
Boris