Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL:MySQL目录的所有权更改为';mysql';从';服务账户';关于linux服务器重新启动_Mysql_Linux_Unix_Mariadb_File Ownership - Fatal编程技术网

MySQL:MySQL目录的所有权更改为';mysql';从';服务账户';关于linux服务器重新启动

MySQL:MySQL目录的所有权更改为';mysql';从';服务账户';关于linux服务器重新启动,mysql,linux,unix,mariadb,file-ownership,Mysql,Linux,Unix,Mariadb,File Ownership,我正在使用MySQL发行版10.2.39-MariaDB,用于Linux(x86_64)。当我们最初启动它并手动配置它以更正所有权和启动时,它运行良好。但每当我们重新启动Linux服务器时,“/var/lib/mysql”的所有权就会从“service_account”更改为“mysql”,如下所示: 重新启动Linux服务器之前 drwxr-xr-x. service_account service-account_grp 4096 Mar 18 14:00 mysql drwxr-xr-x

我正在使用MySQL发行版10.2.39-MariaDB,用于Linux(x86_64)。当我们最初启动它并手动配置它以更正所有权和启动时,它运行良好。但每当我们重新启动Linux服务器时,“/var/lib/mysql”的所有权就会从“service_account”更改为“mysql”,如下所示:

重新启动Linux服务器之前

drwxr-xr-x. service_account service-account_grp 4096 Mar 18 14:00 mysql
drwxr-xr-x. mysql mysql 4096 Mar 18 14:00 mysql

重新启动Linux服务器后

drwxr-xr-x. service_account service-account_grp 4096 Mar 18 14:00 mysql
drwxr-xr-x. mysql mysql 4096 Mar 18 14:00 mysql
它改变了所有权本身,我并没有碰巧找到它的根本原因。 我一直面临着这个问题,我无法找到解决办法

欢迎您的任何意见

提前感谢,


Sid我写这个答案是因为我认为我们都误解了mariadb的机制。我也遇到了这个问题,所以我在为自己写这个答案。你可以按照这个答案或的,无论你真正需要什么。正如danblack所说,将“mysql”更改为您的服务帐户可能不是一个好主意

使用“mysql”用户帐户初始化mariadb数据库目录:

$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
...
Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo
...
如您所见,两个mariadb都是特权帐户,
root@localhost
mysql@localhost
,已创建。您必须是操作系统
root
mysql
用户才能分别使用这两个mariadb帐户

然后,启用并启动mariadb服务器:

$ sudo systemctl enable --now mariadb.service
您可能需要使用
mysql\u secure\u安装
命令来执行此操作

然后使用mariadb
root@localhost
使用系统
根用户的帐户
连接到服务器的帐户,并使用您想要的任何名称:

$ sudo mysql -u root -p  # first input your passwd to use 'sudo', then [ENTER] for empty mariadb root account passwd
[sudo] password for your_service_account:
Enter password:
...
MariaDB [(none)]> CREATE USER 'whatever_name_you_want'@'localhost' IDENTIFIED BY 'somepasswd';
Query OK, 0 rows affected (0.004 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* to 'whatever_name_you_want'@'localhost';
Query OK, 0 rows affected (0.004 sec)

MariaDB [(none)]> quit
Bye
使用新的非特权
无论你叫什么_want@localhost
连接到服务器并创建新数据库的帐户:

$ mysql -u whatever_name_you_want -p
Enter password:
...
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS mydb;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> quit
Bye
如果您为
root@localhost
account,您甚至可以在不使用sudo的情况下使用此帐户:

$ sudo mysql -u root -p
[sudo] password for your_service_account:
Enter password:
...
MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('somepasswd');
Query OK, 0 rows affected (0.041 sec)

MariaDB [(none)]> quit
Bye
$ mysql -u root -p
Enter password:
...
MariaDB [(none)]> quit
Bye

我写这个答案是因为我认为我们都误解了mariadb的机制。我也遇到了这个问题,所以我在为自己写这个答案。你可以按照这个答案或的,无论你真正需要什么。正如danblack所说,将“mysql”更改为您的服务帐户可能不是一个好主意

使用“mysql”用户帐户初始化mariadb数据库目录:

$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
...
Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo
...
如您所见,两个mariadb都是特权帐户,
root@localhost
mysql@localhost
,已创建。您必须是操作系统
root
mysql
用户才能分别使用这两个mariadb帐户

然后,启用并启动mariadb服务器:

$ sudo systemctl enable --now mariadb.service
您可能需要使用
mysql\u secure\u安装
命令来执行此操作

然后使用mariadb
root@localhost
使用系统
根用户的帐户
连接到服务器的帐户,并使用您想要的任何名称:

$ sudo mysql -u root -p  # first input your passwd to use 'sudo', then [ENTER] for empty mariadb root account passwd
[sudo] password for your_service_account:
Enter password:
...
MariaDB [(none)]> CREATE USER 'whatever_name_you_want'@'localhost' IDENTIFIED BY 'somepasswd';
Query OK, 0 rows affected (0.004 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* to 'whatever_name_you_want'@'localhost';
Query OK, 0 rows affected (0.004 sec)

MariaDB [(none)]> quit
Bye
使用新的非特权
无论你叫什么_want@localhost
连接到服务器并创建新数据库的帐户:

$ mysql -u whatever_name_you_want -p
Enter password:
...
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS mydb;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> quit
Bye
如果您为
root@localhost
account,您甚至可以在不使用sudo的情况下使用此帐户:

$ sudo mysql -u root -p
[sudo] password for your_service_account:
Enter password:
...
MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('somepasswd');
Query OK, 0 rows affected (0.041 sec)

MariaDB [(none)]> quit
Bye
$ mysql -u root -p
Enter password:
...
MariaDB [(none)]> quit
Bye

请问,什么是分销?您可以发布
systemctl cat mysql
的内容吗?您可以发布
systemctl cat mysql
的内容吗?请参阅