Skip to contentSkip to conversation

package/mysql: add MYSQL_SOCKET variable

PATCH New Floris Bos 2 participants 3 messages Sep 13, 2016 – Sep 18, 2016

lore
Share & tools
lore

Floris Bos

author
#0 lore raw

PATCH v3 1/2 package/mysql: add MYSQL_SOCKET variable

Add MYSQL_SOCKET variable with MySQL socket location

---
Changes v2 -> v3:
- fix systemd unit file missing User

Changes v1 -> v2:
- move socket to /run/mysql/mysql.sock chmod 755 /run/mysql to allow users access to it

---
 package/mysql/S97mysqld      | 2 +-
 package/mysql/mysql.mk       | 4 ++++
 package/mysql/mysqld.service | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)
package/mysql/S97mysqld +1 -1
index 1d87e68..5a660e9 100644
@@ -9,7 +9,7 @@ case "$1" in
 
 		# mysqld runs as user mysql, but /run is only writable by root
 		# so create a subdirectory for mysql.
-		install -d -o mysql -g root -m 0700 /run/mysql
+		install -d -o mysql -g root -m 0755 /run/mysql
 
 		# We don't use start-stop-daemon because mysqld has
 		# its own wrapper script.
package/mysql/mysql.mk +4 -0
index 534bd97..7af4711 100644
@@ -14,6 +14,9 @@ MYSQL_AUTORECONF = YES
 MYSQL_LICENSE = GPLv2
 MYSQL_LICENSE_FILES = README COPYING
 
+# Unix socket. This variable can also be consulted by other buildroot packages
+MYSQL_SOCKET = /run/mysql/mysql.sock
+
 MYSQL_CONF_ENV = \
 	ac_cv_sys_restartable_syscalls=yes \
 	ac_cv_path_PS=/bin/ps \
@@ -31,6 +34,7 @@ MYSQL_CONF_OPTS = \
 	--without-readline \
 	--with-low-memory \
 	--enable-thread-safe-client \
+	--with-unix-socket-path=$(MYSQL_SOCKET) \
 	--disable-mysql-maintainer-mode
 
 # host-mysql only installs what is needed to build mysql, i.e. the
package/mysql/mysqld.service +3 -0
index 2ded9c2..c9e5e42 100644
@@ -5,6 +5,9 @@ Description=MySQL database server
 ExecStartPre=/bin/sh -c 'test -d /var/mysql/mysql || mysql_install_db --user=mysql --ldata=/var/mysql'
 ExecStart=/usr/bin/mysqld_safe
 Restart=always
+User=mysql
+RuntimeDirectory=mysql
+RuntimeDirectoryMode=0755
 
 [Install]
 WantedBy=multi-user.target
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v3 2/2 package/php: set MySQL socket path

Set the PHP default MySQL socket path to match what the mysql package is using.

---
 package/php/php.mk | 5 +++++
 1 file changed, 5 insertions(+)
package/php/php.mk +5 -0
index 7df10be..1ea47f2 100644
@@ -211,6 +211,11 @@ PHP_DEPENDENCIES += unixodbc
 endif
 endif
 
+ifneq ($(BR2_PACKAGE_PHP_EXT_MYSQLI)$(BR2_PACKAGE_PHP_EXT_PDO_MYSQL),)
+# Set default MySQL unix socket to what the MySQL server is using by default
+PHP_CONF_OPTS += --with-mysql-sock=$(MYSQL_SOCKET)
+endif
+
 define PHP_DISABLE_PCRE_JIT
 	$(SED) '/^#define SUPPORT_JIT/d' $(@D)/ext/pcre/pcrelib/config.h
 endef
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 1/2 package/mysql: add MYSQL_SOCKET variable

In reply to Floris Bos

Hello,

Quoted 7 lines · Floris Bos

Add MYSQL_SOCKET variable with MySQL socket location

---
Changes v2 -> v3:
- fix systemd unit file missing User

Both patches applied to master, thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com