Solved Cannot run mysql_secure_installation

Hi,

I have installed MariaDB using pkg install mariadb100-server and created a /usr/local/etc/my.cnf file.
The server start well but when I try to run /usr/local/bin/mysql_secure_installation, I get the following error:
Code:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")
Where does the system pull the /tmp/mysql.sock path from as my my.cnf file has
Code:
socket  = /var/db/mysql/mysql.sock
Here is the full file:
Code:
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
# Configuration name trinity_mariaDB_server generated for fred@trinitech.co.uk at 2016-02-05 11:50:41


[client]        # The following options will be passed to all MariaDB clients
#password       = your_password
port            = 3306
default-character-set=utf8

[mysql]
no-auto-rehash
default-character-set=utf8


[mysqld]        # The MariaDB server

# GENERAL #
user                           = mysql
port            = 3306
socket          = /var/db/mysql/mysql.sock
bind-address                   = 10.8.20.10
default-storage-engine         = InnoDB
pid-file                       = /var/db/mysql/mariadb.mydomain.co.uk.pid
lc-messages-dir=/usr/local/share/mysql/english/         # Directory for the errmsg.sys file in the language you want to use

# UTF-8 encoding settings #
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8


# MyISAM #
key-buffer-size                = 32M
myisam-recover                 = FORCE,BACKUP

# SAFETY #
max-allowed-packet             = 16M
max-connect-errors             = 1000000
skip-name-resolve
sql-mode                       = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate-is-now                 = 1
innodb                         = FORCE
innodb-strict-mode             = 1
skip-symbolic-links
local-infile                   = 0
explicit_defaults_for_timestamp = TRUE
skip-innodb_doublewrite

# DATA STORAGE #
#datadir                        = /var/db/mysql/
innodb_data_home_dir           = /var/db/mysql/mysql-innodb
innodb_log_group_home_dir      = /var/db/mysql/mysql-innodb-logs

# BINARY LOGGING #
log-bin                        = /var/db/mysql/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1

# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 0
max-connections                = 500
thread-cache-size              = 50
open-files-limit               = 65535
table-definition-cache         = 4096
table-open-cache               = 10240

# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 4G

# LOGGING #
log-error                      = /var/db/mysql/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /var/db/mysql/mysql-slow.log
 
Two ways to solve this. The first is to, temporarily, set the socket back to /tmp/mysql.sock, run the script, then set the socket to where you need. The second is to run the command and add --socket=/var/db/mysql/mysql.sock.
 
SirDice I still got issue when trying to login
Code:
mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")
Why is the path set in my.cnf are not been considered? is that anything to do with the fact that I use zfs and I mounted mysql-innodb and mysql-innodb-logs?
Code:
zfs create zroot/DATA
zfs set mountpoint=none zroot/DATA
zfs create -o recordsize=8k zroot/DATA/mysql
zfs create -o recordsize=128k -o primarycache=metadata zroot/DATA/mysql/mysql-innodb-logs
zfs create -o recordsize=16k -o primarycache=metadata zroot/DATA/mysql/mysql-innodb
zfs set mountpoint=/iocage/jails/<bignum>/root/var/db/mysql zroot/DATA/mysql
zfs set mountpoint=none zroot/DATA
Changing it back to socket = /tmp/mysql.sock seem to work but I would like to understand if possible
 
Last edited by a moderator:
Why is the path set in my.cnf are not been considered?
Because it's only defined in the [mysqld] section, you probably also need to add the socket option to the [client] section. The client and server can have different settings. It's just a matter of making sure both use the same settings.

is that anything to do with the fact that I use zfs and I mounted mysql-innodb and mysql-innodb-logs?
No, this has nothing to do with it.
 
Im also getting the same error.
Code:
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Enter current password for root (enter for none):
I checked /usr/local/etc/my.cnf and socket =/tmp/mysql.sock
Code:
# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id       = 1

I also tried changing socket=/var/db/mysql/mysql.sock in the "# The following options will be passed to all MySQL clients" section and the "# The MySQL server" section.

I'm totally new to this, only been playing with FreeBSD for a week or so.

What am I missing. Any help would be much appreciated
Thank You
Ed
 
Code:
Enter current password for root (enter for none): 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Don't overlook the obvious, is MySQL/MariaDB actually running?
 
Back
Top