MySQL无法启动:[错误]无法为IPv4'127.0.0.1'创建套接字:errno:13

Gyu*_*rli 3 mysql networking debian android pymysql

我将在chroot环境中将低流量的Web服务器设置到旧的Android手机上。Debian已安装到手机上,并且可以正常工作数月(因此,这是一种特殊的Linux环境)。

Apache2和Python已启动并正在运行。

但是当我启动mysqld时:

root@Motoluxe:~# /usr/sbin/mysqld
... [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
... [Note] /usr/sbin/mysqld (mysqld 5.5.49-0+deb7u1) starting as process 31419 ...
... [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
... [Note] Plugin 'FEDERATED' is disabled.
... InnoDB: The InnoDB memory heap is disabled
... InnoDB: Mutexes and rw_locks use GCC atomic builtins
... InnoDB: Compressed tables use zlib 1.2.7
... InnoDB: Using Linux native AIO
... InnoDB: Initializing buffer pool, size = 128.0M
... InnoDB: Completed initialization of buffer pool
... InnoDB: highest supported file format is Barracuda.
... InnoDB: Waiting for the background threads to start
... InnoDB: 5.5.49 started; log sequence number 1598476
... [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
... [Note]   - '127.0.0.1' resolves to '127.0.0.1';
... [ERROR] Failed to create a socket for IPv4 '127.0.0.1': errno: 13.
... [ERROR] Can't create IP socket: Permission denied
... [ERROR] Aborting
...  InnoDB: Starting shutdown...
...  InnoDB: Shutdown completed; log sequence number 1598476
... [Note] /usr/sbin/mysqld: Shutdown complete
Run Code Online (Sandbox Code Playgroud)

在/etc/mysql/my.conf中:

#skip-networking
...
socket          = /var/run/mysqld/mysqld.sock
Run Code Online (Sandbox Code Playgroud)

在/ var / run中:

drwxrwxrwx 2 mysql mysql 4096年6月19日10:07 mysqld

因此,理论上可以编写套接字。

(如果我启用了跳过网络功能,则 mysql启动但无法通过pymysql.connect从python连接到它)

值得注意的是,/ etc / groups似乎是不完整的,而且我看到没有名称的组只有一个ID(在目录列表中),因此某种mysql-is-being-in-that-group-wow -a-网络资源类型的问题是可以想到的。

其他网络使用程序,包括apache2工作。

PS启用python以启用跳过网络连接应该是一种解决方法。

小智 5

这可能是因为您的Android内核已使用CONFIG_ANDROID_PARANOID_NETWORK进行了编译。您可以通过将mysql用户添加到aid_inet和aid_net_raw组来修复它。

之前:

[mysql@81fc75b0d254466b ~]$ mysqld
2017-04-16  8:25:07 4143896512 [Note] mysqld (mysqld 10.1.22-MariaDB) starting as process 6995 ...
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2017-04-16  8:25:08 4143896512 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-16  8:25:08 4143896512 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Compressed tables use zlib 1.2.11
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Using Linux native AIO
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Using generic crc32 instructions
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Completed initialization of buffer pool
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Highest supported file format is Barracuda.
2017-04-16  8:25:08 4143896512 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-16  8:25:08 4143896512 [Note] InnoDB: Waiting for purge to start
2017-04-16  8:25:08 4143896512 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.35-80.0 started; log sequence number 1616819
2017-04-16  8:25:08 4143896512 [Note] Plugin 'FEEDBACK' is disabled.
2017-04-16  8:25:08 3630140224 [Note] InnoDB: Dumping buffer pool(s) not yet started
2017-04-16  8:25:08 4143896512 [Warning] Failed to create a socket for IPv6 '::': errno: 13.
2017-04-16  8:25:08 4143896512 [Warning] Failed to create a socket for IPv4 '0.0.0.0': errno: 13.
2017-04-16  8:25:08 4143896512 [ERROR] Can't create IP socket: Permission denied
2017-04-16  8:25:08 4143896512 [ERROR] Aborting
Run Code Online (Sandbox Code Playgroud)

后:

[root@81fc75b0d254466b mysqld]# usermod -a -G aid_inet,aid_net_raw mysql
[root@81fc75b0d254466b mysqld]# su mysql
[mysql@81fc75b0d254466b mysqld]$ mysqld
2017-04-16  9:56:00 4144179136 [Note] mysqld (mysqld 10.1.22-MariaDB) starting as process 7246 ...
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2017-04-16  9:56:00 4144179136 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-16  9:56:00 4144179136 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Compressed tables use zlib 1.2.11
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Using Linux native AIO
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Using generic crc32 instructions
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Completed initialization of buffer pool
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Highest supported file format is Barracuda.
2017-04-16  9:56:00 4144179136 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-16  9:56:00 4144179136 [Note] InnoDB: Waiting for purge to start
2017-04-16  9:56:00 4144179136 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.35-80.0 started; log sequence number 1616869
2017-04-16  9:56:00 4144179136 [Note] Plugin 'FEEDBACK' is disabled.
2017-04-16  9:56:00 3632237376 [Note] InnoDB: Dumping buffer pool(s) not yet started
2017-04-16  9:56:00 4144179136 [Note] Server socket created on IP: '::'.
2017-04-16  9:56:00 4144179136 [Note] mysqld: ready for connections.
Version: '10.1.22-MariaDB'  socket: '/run/mysqld/mysqld.sock'  port: 3306  MariaDB Server
Run Code Online (Sandbox Code Playgroud)

另请参阅/sf/answers/2551601181/

Linux 81fc75b0d254466b 4.4.40-android-x86_64 #2 SMP PREEMPT Fri Jan 13 22:40:54 CST 2017 x86_64 GNU/Linux在Archlinux chroot中使用进行了测试mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (i686)