When installing mysql on Linux, Permission denied appears no matter how the permissions and users are modified.

Preface

Since a large amount of data needs to be stored later, the data storage location of mysql needs to be set on a large-capacity hard disk. At the
earliest, try to use apt-get to install mysql. Follow the tutorial to set the new storage location, including creating a new data folder, and Use sudo vim /etc/mysql/mysql.conf.d/mysqld.cnfand sudo vim /usr/share/mysql/mysql-systemd-startto modify the new storage location. Use chmod and chown to set the permissions of the new storage location, but the error still occurs. Permission denied
Therefore, in order to install using the method in this article, the newly obtained mysql-8.0folder is set under mysql:mysqlthe user and user group, and all the files in it are inherited mysql:mysql. After startup, the error still occurs.Permission denied

solve

I accidentally set the outer folder mysql-8.0to the currently logged in user, and the initialization command was successfully executed!
The following is the file structure and permissions

drwxr-xr-x 10 lab105 lab105      4096 Sep  2 17:12 mysql-8.0/

After entering: (It should be noted that the data is automatically generated and not created by the user, otherwise an error will be reported)

drwxr-xr-x  2 mysql  mysql    4096 Jun 17  2020 bin/
drwxr-x---  6 lab105 lab105   4096 Sep  2 17:13 data/
drwxr-xr-x  2 mysql  mysql    4096 Jun 17  2020 docs/
drwxr-xr-x  3 mysql  mysql    4096 Jun 17  2020 include/
drwxr-xr-x  6 mysql  mysql    4096 Jun 17  2020 lib/
-rw-r--r--  1 mysql  mysql  404759 Jun 17  2020 LICENSE
drwxr-xr-x  4 mysql  mysql    4096 Jun 17  2020 man/
-rw-r--r--  1 mysql  mysql     687 Jun 17  2020 README
drwxr-xr-x 28 mysql  mysql    4096 Jun 17  2020 share/
drwxr-xr-x  2 mysql  mysql    4096 Jun 17  2020 support-files/

Guess you like

Origin blog.csdn.net/qq_29391809/article/details/132640539