Mysql 5.7 Could not create unix socket lock file - mysql

I am trying to create multiple instances of MySQL 5.7 in the same Ubuntu 16.10 32-bit box. I have copied the original data dir to the new one. Created separate log folder for the new instance(the logs are working). Changed the owner to mysql:mysql for the new data dir /var/lib/mysql2 and log dir /var/log/mysql2/. I have removed app-armor. I have posted this Question only after going through the other SO answers...none of which address the multiple instance issue.
Here is my my2.cnf:
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld2.pid
socket = /var/run/mysqld/mysqld2.sock
port = 3307
basedir = /usr
datadir = /var/lib/mysql2
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
#max_connections = 100
#table_open_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
[mysqld_safe]
socket = /var/run/mysqld/mysqld2.sock
nice = 0
As you can see I have changed the port to 3307 and others respectively. Now when I run (have to add the sudo to mysqld):
sudo mysqld --defaults-file=/etc/mysql/my2.cnf &
I receive:
2017-03-22T08:31:21.684121Z 0 [Note] mysqld (mysqld 5.7.17-0ubuntu0.16.10.1) starting as process 13676 ...
2017-03-22T08:31:21.687115Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-03-22T08:31:21.687131Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-03-22T08:31:21.687135Z 0 [Note] InnoDB: Uses event mutexes
2017-03-22T08:31:21.687140Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-03-22T08:31:21.687143Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-03-22T08:31:21.687147Z 0 [Note] InnoDB: Using Linux native AIO
2017-03-22T08:31:21.687281Z 0 [Note] InnoDB: Number of pools: 1
2017-03-22T08:31:21.687344Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2017-03-22T08:31:21.688116Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-03-22T08:31:21.693801Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-03-22T08:31:21.694846Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the $
2017-03-22T08:31:21.708807Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-03-22T08:31:21.776053Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-03-22T08:31:21.776228Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-03-22T08:31:21.825266Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-03-22T08:31:21.826338Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-03-22T08:31:21.826359Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-03-22T08:31:21.826695Z 0 [Note] InnoDB: Waiting for purge to start
2017-03-22T08:31:21.880277Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 2535531
2017-03-22T08:31:21.881286Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql2/ib_buffer_pool
2017-03-22T08:31:21.881581Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-03-22T08:31:21.887687Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170322 14:01:21
2017-03-22T08:31:21.890330Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without cer$
2017-03-22T08:31:21.890380Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3307
2017-03-22T08:31:21.890407Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2017-03-22T08:31:21.890695Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2017-03-22T08:31:21.890791Z 0 [ERROR] Could not create unix socket lock file /var/run/mysqld/mysqld2.sock.lock.
2017-03-22T08:31:21.890807Z 0 [ERROR] Unable to setup unix socket lock file.
2017-03-22T08:31:21.890819Z 0 [ERROR] Aborting
What am I missing?

check whether there is a lock file
ls /var/run/mysqld/mysqld2.sock.lock
1. if exists
1.1 check which process use the lock file
lsof /var/run/mysqld/mysqld2.sock.lock
1.1.1 if there is not a process using the lock file
rm lock file
rm /var/run/mysqld/mysqld2.sock.lock
and then start mysql
1.1.2 if there is a process using the lock file
change lock file and socket file to another path
2. if not exists
need more information to check what is happing
strace -ff mysqld --defaults-file=/etc/mysql/my2.cnf

For those who are using apparmor the following permissions in /etc/apparmor.d/usr.sbin.mysqld allowed mysqld to create and use the lock file.
/var/run/mysqld/mysqld2.pid rw,
/var/run/mysqld/mysqld2.sock rw,
/var/run/mysqld/mysqld2.sock.lock rw,
Then run the following as root to reload the profile.
apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld
For some reason i got OP's error without rw permissions on all three of these files.

Related

MariaDB doesn't connect to galera cluster despite reading configuration file

I'm trying to setup a galera cluster using MariaDB 10.6.11. It's something I've done several times without any problems, now I'm trying to automate the process and something weird happens.
I have a configuration file /etc/my.cnf.d/galera.cnf like this on every node:
[mysqld]
datadir=/var/lib/mysql
[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider="/usr/lib64/galera-4/libgalera_smm.so"
wsrep_provider_options="gcache.size=300M; gcache.page_size=200M"
wsrep_cluster_name="test"
wsrep_cluster_address="gcomm://192.168.1.176,192.168.1.61"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
wsrep_sst_method=mariabackup
wsrep_sst_auth="backup:[redacted]"
# Log Options
wsrep_log_conflicts=ON
wsrep_provider_options="cert.log_conflicts=ON"
# Optional setting
#wsrep_slave_threads=1
innodb_flush_log_at_trx_commit=0
# Node Specific
wsrep_node_name="node-1"
bind-address="192.168.1.61"
Of course, in the other nodes bind-address and wsrep_node_name are set accordingly.
Anyway, I start the first node with
galera_new_cluster
And the cluster is started correctly, with one synced node as expected.
When I execute systemctl start mariadb on other node instead, after the first node is online, the second node starts in standalone mode, completely ignoring the galera configuration.
If I execute mariadbd --print-defaults on the second node, I see all the variables correctly set
[root#localhost ~]# mariadbd --print-defaults
mariadbd would have been started with the following arguments:
--datadir=/var/lib/mysql --wsrep_on=ON
--wsrep_provider=/usr/lib64/galera-4/libgalera_smm.so --wsrep_provider_options=gcache.size=300M; gcache.page_size=200M
--wsrep_cluster_name=test --wsrep_cluster_address=gcomm://192.168.1.176,192.168.1.61 --binlog_format=row --default_storage_engine=InnoDB
--innodb_autoinc_lock_mode=2 --wsrep_sst_method=mariabackup
--wsrep_sst_auth=backup:[redacted] --wsrep_log_conflicts=ON --wsrep_provider_options=cert.log_conflicts=ON
--innodb_flush_log_at_trx_commit=0 --wsrep_node_name=node-2 --bind-address=192.168.1.176
No attempt to join the cluster is made, it just starts as a standalone node.
From journactl:
2022-11-29 9:15:46 0 [Note] /usr/sbin/mariadbd (server 10.6.11-MariaDB) starting as process 5411 ...
2022-11-29 9:15:46 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-11-29 9:15:46 0 [Note] InnoDB: Number of pools: 1
2022-11-29 9:15:46 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-11-29 9:15:46 0 [Note] InnoDB: Using Linux native AIO
2022-11-29 9:15:46 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-11-29 9:15:46 0 [Note] InnoDB: Completed initialization of buffer pool
2022-11-29 9:15:46 0 [Note] InnoDB: 128 rollback segments are active.
2022-11-29 9:15:46 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-11-29 9:15:46 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-11-29 9:15:46 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-11-29 9:15:46 0 [Note] InnoDB: 10.6.11 started; log sequence number 50748; transaction id 29
2022-11-29 9:15:46 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-11-29 9:15:46 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-11-29 9:15:46 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-11-29 9:15:46 0 [Note] Server socket created on IP: '::'.
2022-11-29 9:15:46 0 [Note] InnoDB: Buffer pool(s) load completed at 221129 9:15:46
2022-11-29 9:15:46 0 [Note] /usr/sbin/mariadbd: ready for connections.
Version: '10.6.11-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
Started MariaDB 10.6.11 database server.
In /etc/my.cnf I have the line
!includedir /etc/my.cnf.d
so that's covered.
Communication between the two nodes is also ok, I opened every needed port. Also, if it were to be something about communication, I'd receive a timeout error or something.
Also, if I move the galera configuration to /etc/my.cnf.d/server.cnf, it works.
I'm confused. The variables are set correctly, what could it be?
One argument could be that in server.cnf there is an empty [galera] section, but I have it also on the first node and everything works there. Plus, again, the variables are set, so it's not like that empty section is overwriting my configuration.
Ideas?

Galera Mysql wsrep_cluster_status stays Disconnected

My cluster was previously running, I have made these config changes and now Galera cluster bootstrap is not working.
I tried bootstraping with /usr/bin/mysqld_bootstrap as well as service mysql start --wsrep-new-cluster . but no luck.
mysql> SHOW GLOBAL STATUS WHERE Variable_name IN ('wsrep_ready', 'wsrep_cluster_size', 'wsrep_cluster_status', 'wsrep_connected');
+----------------------+--------------+
| Variable_name | Value |
+----------------------+--------------+
| wsrep_cluster_size | 0 |
| wsrep_cluster_status | Disconnected |
| wsrep_connected | OFF |
| wsrep_ready | ON |
+----------------------+--------------+
4 rows in set (0.00 sec)
root#hostname:/var/lib/mysql# cat /etc/my.cnf
[mysqld]
# character set
character_set_server = utf8
collation_server = utf8_general_ci
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
binlog_format=ROW
# Galera Cluster Configuration
wsrep_node_address="ip"
wsrep_node_name="hostname"
wsrep_cluster_name="mysql_cluster"
wsrep_cluster_address="gcomm://"
wsrep_provider_options = "gcache.size = 16G; gcache.recover = yes; gmcast.segment=0; gmcast.time_wait=PT5S; cert.log_conflicts=ON;"
wsrep_retry_autocommit=5
wsrep_slave_threads=64
wsrep_log_conflicts=ON
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_sst_method=rsync # Galera Synchronization Configuration
# wsrep_certify_nonPK=1 # make sure primary key is present in a DB
# Mysql configurations
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=2
innodb_buffer_pool_size=20G # 80% of total memory
table_open_cache=8192
max_connections=500
innodb_buffer_pool_instances=40
thread_cache_size=128
max_allowed_packet=16M
thread_stack=192K
[mysql_safe]
log-error=/var/log/mysql/error.log
pid-file=/var/run/mysqld/mysqld.pid
#include mysql config
!includedir /etc/mysql/conf.d/
error.log
2020-05-10T14:52:11.510387Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-10T14:52:11.512408Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-log) starting as process 38762 ...
2020-05-10T14:52:11.516208Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-10T14:52:11.516233Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-10T14:52:11.516240Z 0 [Note] InnoDB: Uses event mutexes
2020-05-10T14:52:11.516246Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-10T14:52:11.516251Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-10T14:52:11.516259Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-10T14:52:11.516566Z 0 [Note] InnoDB: Number of pools: 1
2020-05-10T14:52:11.516689Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-10T14:52:11.518701Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-05-10T14:52:11.528085Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-05-10T14:52:11.530536Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-05-10T14:52:11.542537Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-05-10T14:52:11.559072Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-05-10T14:52:11.559138Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-05-10T14:52:11.601120Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-05-10T14:52:11.602357Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-05-10T14:52:11.602377Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-05-10T14:52:11.602854Z 0 [Note] InnoDB: Waiting for purge to start
2020-05-10T14:52:11.653077Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 3779657135
2020-05-10T14:52:11.653388Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-05-10T14:52:11.653670Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-05-10T14:52:11.656614Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200510 7:52:11
2020-05-10T14:52:11.665175Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-05-10T14:52:11.665203Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-05-10T14:52:11.666274Z 0 [Warning] CA certificate ca.pem is self signed.
2020-05-10T14:52:11.666344Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-05-10T14:52:11.667341Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-05-10T14:52:11.667427Z 0 [Note] IPv6 is available.
2020-05-10T14:52:11.667444Z 0 [Note] - '::' resolves to '::';
2020-05-10T14:52:11.667487Z 0 [Note] Server socket created on IP: '::'.
2020-05-10T14:52:11.686718Z 0 [Note] Event Scheduler: Loaded 0 events
2020-05-10T14:52:11.686771Z 0 [Note] WSREP: Initial position: 00000000-0000-0000-b0f1-bf0300000000:62901600
2020-05-10T14:52:11.686784Z 0 [Warning] WSREP: Initial position was provided by configuration or SST, avoiding override
2020-05-10T14:52:11.686792Z 0 [Note] WSREP: wsrep_load(): loading provider library 'none'
2020-05-10T14:52:11.687082Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.29-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Wsrep Server (GPL), wsrep_25.21
2020-05-10T14:52:12.732431Z 2 [Note] Access denied for user 'root'#'localhost' (using password: NO)
2020-05-10T14:57:11.957879Z 4 [Note] WSREP: Stop replication
2020-05-10T14:57:11.957918Z 4 [Note] Giving 1 client threads a chance to die gracefully
Make sure it belongs to mysql user and mysql group
chown mysql:mysql /etc/my.cnf
Also, and very important, make sure the library is in /etc/my.cnf
symbolic-links=0
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
The file /etc/my.cnf was missing read permissions. This file requires read permission for mysql user. I have set the permission to 755 and Galera configuration was loaded properly.
chmod 775 /etc/my.cnf

MySQL not starting on XAMP and HeidiSQL

I cannot start MySQL with XAMPP and I do not get any errors. So if I click on "Start", I get the message "01:26:41 [mysql] Attempting to start MySQL service..." and that's it.
The problem may be, because I have also installed HeidiSQL, which comes with MariaDB. I know that both of them use the same port (3306) and I have tried to change the port of MariaDB to 3308.
This is the content of my.ini:
[mysqld]
port= 3306
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql"
tmpdir = "C:/xampp/tmp"
datadir = "C:/xampp/mysql/data"
pid_file = "mysql.pid"
# enable-named-pipe
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log_error = "mysql_error.log"
datadir=C:/Program Files/MariaDB 10.3/data
port=3308
innodb_buffer_pool_size=2033M
character-set-server=utf8
[client]
port=3308
plugin-dir=C:/Program Files/MariaDB 10.3/lib/plugin
mysql_error.log:
2019-07-24 1:18:11 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2019-07-24 1:18:11 0 [Note] InnoDB: Uses event mutexes
2019-07-24 1:18:11 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-07-24 1:18:11 0 [Note] InnoDB: Number of pools: 1
2019-07-24 1:18:11 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-07-24 1:18:11 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M
2019-07-24 1:18:11 0 [Note] InnoDB: Completed initialization of buffer pool
2019-07-24 1:18:11 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1791378
2019-07-24 1:18:11 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-07-24 1:18:11 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-07-24 1:18:11 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-07-24 1:18:11 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-07-24 1:18:11 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB.
2019-07-24 1:18:11 0 [Note] InnoDB: Waiting for purge to start
2019-07-24 1:18:11 0 [Note] InnoDB: 10.3.16 started; log sequence number 1791387; transaction id 163
2019-07-24 1:18:11 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2019-07-24 1:18:11 0 [Note] InnoDB: Buffer pool(s) load completed at 190724 1:18:11
2019-07-24 1:18:11 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-07-24 1:18:11 0 [Note] Server socket created on IP: '::'.
2019-07-24 1:18:11 0 [Note] Reading of all Master_info entries succeeded
2019-07-24 1:18:11 0 [Note] Added new Master_info '' to hash table
2019-07-24 1:18:11 0 [Note] mysql\bin\mysqld.exe: ready for connections.
Version: '10.3.16-MariaDB' socket: '' port: 3307 mariadb.org binary distribution
I have tried all answers from that questions but none of them worked for me.
Not only XAMPP, I can't even get a connection with HeidiSQL. The error message is:
Can't connect to MySQL server on '127.0.0.1' (10061)
I have uninstalled both of them, XAMPP and HeidiSQL and installed them again. Even that didn't help. Any help would be appreciated!
HeidiSQL would just connect over port 3306 to your MySQL instance, but it does not listen to any port, so it does not use any port as you say.
So your problem is the non-starting MySQL service.
Your my.ini looks as if you already have two services running:
one from C:\Program Files\MariaDB 10.3\
and one from C:\xampp\mysql\
Have a look in your services control panel, e.g. by running services.msc from your start menu. Then, watch out for services named "MySQL" or "MariaDB", or one with some version number in it.
Your my.ini contains two port definitions in the [mysqld] section, which could mean your Xamp/MySQL still wants port 3306, ignoring the later 3308. That again would explain why your service does not start, if your MariaDB service still runs.
Not knowing anything about the intention for installing MariaDB, I'd recommend to uninstall it, or at least change the service startup option to manually:

MySql startup error ' ERROR! The server quit without updating PID file'

I have tried every link that is on S.O but still getting the same outcome every time I try to start MySQL. Following is the log from the .err file.
2018-01-07T06:58:11.729500Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-01-07T06:58:11.731659Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-01-07T06:58:11.731673Z 0 [Note] InnoDB: Uses event mutexes
2018-01-07T06:58:11.731679Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-01-07T06:58:11.731682Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-01-07T06:58:11.731969Z 0 [Note] InnoDB: Number of pools: 1
2018-01-07T06:58:11.732068Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-01-07T06:58:11.733672Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-01-07T06:58:11.745339Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-01-07T06:58:11.761905Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-01-07T06:58:11.906535Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-01-07T06:58:11.906692Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-01-07T06:58:11.918639Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-01-07T06:58:11.919925Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-01-07T06:58:11.919938Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-01-07T06:58:11.920116Z 0 [Note] InnoDB: Waiting for purge to start
2018-01-07T06:58:11.974340Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 129183358
2018-01-07T06:58:11.974571Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2018-01-07T06:58:11.974744Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-01-07T06:58:11.974853Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180107 12:28:11
2018-01-07T06:58:11.983233Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-01-07T06:58:11.983254Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2018-01-07T06:58:11.983981Z 0 [Warning] CA certificate ca.pem is self signed.
2018-01-07T06:58:11.984032Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2018-01-07T06:58:11.989041Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-01-07T06:58:11.989070Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2018-01-07T06:58:11.989136Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-01-07T06:58:11.989166Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
2018-01-07T06:58:11.989169Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2018-01-07T06:58:11.989199Z 0 [ERROR] Aborting
It looks like you have some other software that is using the port 3306. MySQL uses this port, but it's failing to bind to it because it is in use. End the other software and try to launch MySQL again.
If you need to have the other software running at the same time with MySQL, you have to change the default port in one of them to some other unused port.
To change the port in MySQL. If you're on Windows, find the my.ini file for MySQL installation, open this file in a text editor and look for this section:
# The TCP/IP Port the MySQL Server will listen on
port=3306
Then change the number of the port, save the file, and restart the MySQL service.

MySQL won't start on Linux

I have a fresh mysql-server install (installed via yum) that will not start
bash-4.1# /sbin/service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
The /etc/my.cnf has been set to default:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
The error I receive is:
2016-02-16T22:47:18.453320Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2016-02-16T22:47:18.888497Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-16T22:47:18.889955Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.11) starting as process 4321 ...
2016-02-16T22:47:19.016515Z 0 [Note] InnoDB: PUNCH HOLE support available
2016-02-16T22:47:19.016568Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-16T22:47:19.016583Z 0 [Note] InnoDB: Uses event mutexes
2016-02-16T22:47:19.016596Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2016-02-16T22:47:19.016609Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-16T22:47:19.016631Z 0 [Note] InnoDB: Using Linux native AIO
2016-02-16T22:47:19.018127Z 0 [Note] InnoDB: Number of pools: 1
2016-02-16T22:47:19.018819Z 0 [Note] InnoDB: Using CPU crc32 instructions
2016-02-16T22:47:19.052517Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2016-02-16T22:47:19.071855Z 0 [Note] InnoDB: Completed initialization of buffer pool
2016-02-16T22:47:19.078235Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2016-02-16T22:47:19.092945Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2016-02-16T22:47:19.107542Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2016-02-16T22:47:19.107588Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2016-02-16T22:47:19.160738Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2016-02-16T22:47:19.163712Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2016-02-16T22:47:19.163748Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2016-02-16T22:47:19.165210Z 0 [Note] InnoDB: Waiting for purge to start
2016-02-16T22:47:19.215586Z 0 [Note] InnoDB: 5.7.11 started; log sequence number 1210437
2016-02-16T22:47:19.216328Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2016-02-16T22:47:19.217459Z 0 [Note] Plugin 'FEDERATED' is disabled.
2016-02-16T22:47:19.217537Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160216 22:47:19
mysqld: Table 'mysql.plugin' doesn't exist
2016-02-16T22:47:19.217905Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-02-16T22:47:19.219399Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-02-16T22:47:19.219650Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2016-02-16T22:47:19.220055Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-02-16T22:47:19.220231Z 0 [Note] IPv6 is available.
2016-02-16T22:47:19.220261Z 0 [Note] - '::' resolves to '::';
2016-02-16T22:47:19.220280Z 0 [Note] Server socket created on IP: '::'.
2016-02-16T22:47:19.233206Z 0 [Warning] Failed to open optimizer cost constant tables
2016-02-16T22:47:19.233439Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2016-02-16T22:47:19.233551Z 0 [ERROR] Aborting
However, I can't run mysql_upgrade as mysqld isn't running. Other sites have stated that file permissions of the data files could be an issue, but they are all owned by mysql (i.e. I believe correct). I've also tried running mysqld_safe, but without success.
Can someone please suggest what I've done wrong?
Thanks Mark.
mysql_install_db didn't work (was deprecated, and then the suggested initialise failed). However, a complete clean and reinstall resolved the issue.
For reference, the exact steps I performed were:
yum remove mysql
rm -fr /usr/bin/mysql
rm -fr /var/lib/mysql
rm -fr /etc/my*
(reboot)
yum install mysql-community-{server,client,common,libs}-*
/sbin/service mysqld start