I am trying to start mariadb with systemctl start mariadb also tried using sudo along.
This is what it says
Job for mariadb.service failed because the control process exited with
error code. See "systemctl status mariadb.service" and "journalctl
-xe" for details.
I saw this at many places but nothing helped.
It fails, I removed, installed again, nothing happened.
This is a part of /var/log/messages
Jun 17 18:03:09 controller systemd: Starting MariaDB 10.1 database
server...
Jun 17 18:03:09 controller mysqld: 2016-06-17 18:03:09 140477178509440
[Note] /usr/libexec/mysqld (mysqld 10.1.12-MariaDB) starting as process 120408 ...
Jun 17 18:03:12 controller systemd: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jun 17 18:04:13 controller systemd: mariadb.service: control process exited, code=exited status=3
Jun 17 18:04:13 controller systemd: Failed to start MariaDB 10.1 database server.
Jun 17 18:04:13 controller systemd: Unit mariadb.service entered failed state.
Jun 17 18:04:13 controller systemd: mariadb.service failed.
I am really new to CentOS and mariadb, so I don't know how to proceed.
EDIT
The mariadb.log says
2016-06-17 19:24:39 140652810123392 [Note] Server socket created on IP: '::'.
2016-06-17 19:24:39 140652810123392 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 98: Address already in use
2016-06-17 19:24:39 140652810123392 [ERROR] Do you already have another mysqld server running on port: 3306 ? 2016-06-17 19:24:39 140652810123392 [ERROR] Aborting
This is my my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# This group is read by the server
#
[mysqld]
port=5555
bind-address = 10.23.77.68
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
I tried adding a line in my.cnf
port=5555
Didn't help, mariadb.log says the same thing as I have mentioned earlier.
I solved as follows:
After installing
Run: > mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/
Then: >mysql_secure_installation
And then: systemctl start mariadb
With this this, I can resolved.
Just remove following files at location
/var/lib/mysql
ib_logfile0
ib_logfile1
fuser -k 3306/tcp will solve the probem.
-k is to Kill processes accessing the file.
Related
Operating System: Ubuntu 18.04
MySQL version: Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)
My system is set-up so that Ubuntu is running on a 128gb SSD, with a separate 1TB SSD for storage. This system is dual-boot with Windows 10 Pro and Ubuntu 18.04. The storage drive is NTFS formatted.
I would like to move the MySQL datadir over to the storage drive, because my OS drive isn't big enough.
I've been following the tutorial on this URL: https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04
I've gotten to "Step 4 — Restarting MySQL" in the tutorial. Up to this point, I've followed everything to a T, no missed commas, forward slashes, etc. All done exactly as described (I've checked to make sure this is true numerous times)
When I enter the terminal command
sudo systemctl start mysql
I get the following output
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Following this output, I enter the following command into the terminal
systemctl status mysql.service
and receive the following output
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-03-31 22:36:46 CDT; 38s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 7368 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 7316 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 7368 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 13 (Permission denied)
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.436713Z 0 [Warning] [MY-010091] [Server] Can't create test file /media/user/storage/mysql_datadir/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.436796Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 7368
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.439912Z 0 [Warning] [MY-010091] [Server] Can't create test file /media/user/storage/mysql_datadir/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.439923Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /media/user/storage/mysql_datadir/mysql/ is case insensitive
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.439961Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/media/user/storage/mysql_datadir/mysql/' (OS errno: 13 - Permission denied)
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.440049Z 0 [ERROR] [MY-010119] [Server] Aborting
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.440146Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.
Mar 31 22:36:46 user-desktop systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Mar 31 22:36:46 user-desktop systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 31 22:36:46 user-desktop systemd[1]: Failed to start MySQL Community Server.
Seeing that this was a permissions error (which should have been avoided using the -av tags when copying the original directory to the new drive) I entered in the following command to give open permissions to the entire drive.
sudo chmod a+rwx /media/user/storage/
to check the permissions I enter
ls -ls /media/user/storage/mysql_datadir
with output
total 12
12 drwxrwxrwx 1 root root 12288 Mar 31 02:45 mysql
I've also made sure the full file path to the new datadir is lowercase to avoid conflict between the two file systems.
I still cannot get MySQL to start.
I'd appreciate any help. Thank you in advance.
Edit:
namei -mo /media/user/storage/mysql_datadir
f: /media/user/storage/mysql_datadir
drwxr-xr-x root root /
drwxr-xr-x root root media
drwxr-x--- root root user
drwxrwxrwx root root storage
drwxrwxrwx root root mysql_datadir
Based on your post seems that you are having permission issue along with owner of the "data directory" must always be mysql.
STOP your mysql service if it's running.
Consider below example:
my.cnf looks:
#
# Original path change to avoid space issue on server
#
datadir=/var/lib/mysql
Now you change this datadir in your my.cnf file like:
#
# Original path change to avoid space issue on server
#
#datadir=/var/lib/mysql
datadir=/media/user/storage/mysql_datadir
After this check the permission:
cd /media/user/storage/mysql_datadir
ls -al
output:
drwxr-x--x 40 mysql mysql 4096 Mar 27 00:01 mysql
If this is not output then execute below command:
chmod -Rf 0751 /media/user/storage/mysql_datadir
chown -Rf mysql:mysql /media/user/storage/mysql_datadir
Finally
START your mysql service now.
I had the same problem/solution as Pratik, after following the instructions to define a new datadir in
/etc/mysql/mysql.conf.d/mysqld.conf
and
/etc/apparmor.d/usr.sbin.mysqld
I modified my fstab to mount to
/mnt
instead of
/media/[username]
and mysql start up without any errors. no additional permissions to set other than the mysql directory. My issue was on Ubuntu 18.04 must be something special about the /media mount point
I have a problem to move the default datadir of Maria DB to another partition, it appears to be very common but i tried everything I can without luck.
Mysql is installed as Mariadb 10.1.26 with the default debian package (apt-get install mysql-server) on a Debian 9.1 (stretch) server, mysqld -v returns mysqld 10.1.26-MariaDB-0+deb9u1
Default_mysql_datadir : /var/lib/mysql
New_mysql_datadir : /home/mysql
/var/lib/mysql is mounted to "/" (/dev/md3)
/home/mysql is mounted to "/home" (/dev/md4)
What I've tried
# systemctl stop mysql
# mv /var/lib/mysql /home
Change datadir in /etc/mysql/my.cnf
# datadir = /home/mysql
Check if the rights/permissions are ok
# chown -R mysql.mysql /home/mysql
apparmor is NOT installed nor running on the system though the /etc/apparmor.d/usr.sbin.mysqld file is existing with the following rules :
/home/mysql/ r,
/home/mysql/** rwk,
I even tried to create and empty /var/lib/mysq folder refering to this bug
But when I start I always get the same error :
# systemctl start mysql
[Warning] Can't create test file /home/mysql/<user>.lower-test
#007/usr/sbin/mysqld: Can't change dir to '/home/mysql/' (Errcode: 13 "Permission denied") 2017-09-07 0:16:59 140119808397888 [ERROR] Aborting
mariadb.service: Main process exited, code=exited, status=1/FAILURE
Failed to start MariaDB database server.
mariadb.service: Unit entered failed state.
mariadb.service: Failed with result 'exit-code'.
Any suggestion ?
Thanks
Services started by Systemd have additional filesystem restrictions imposed by systemd.
It should be possible to provide values to systemd [Service] directives ProtectHome= and/or ProtectSystem= and/or ReadWritePaths= to resolve this issue.
I have similar problem:
When I start the mysql services a message is shown:
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
if I change the datadir from /etc/mysql/my.cnf again as default; np
i installed mysql 5.7 but then found out I need mysql 5.6 so i deleted all mysql related packages with
apt-get remove --purge mysql*
so it gotten removed. then i issued:
apt-get install mysql-server-5.6 mysql-client-5.6
so the mentioned packages gotten installed.
but its not starting using systemctl start mysql or service mysql start or even restart. the result is this:
service mysql restart
or
service mysql start
or
systemctl restart mysql
or
systemctl start mysql
returns:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
but
systemctl status mysql
returns
mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-04-10 13:24:00 EDT; 29s ago
Docs: man:systemd-sysv-generator(8)
Process: 15820 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
Main PID: 1323 (code=exited, status=0/SUCCESS)
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Compressed tables use zlib 1.2.8
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using Linux native AIO
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using CPU crc32 instructions
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Initializing buffer pool, size = 128.0M
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
Apr 10 13:24:00 server mysql[15820]: ...fail!
Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
what is Failed to start LSB: Start and stop the mysql database server daemon.
before installing 5.6 the 5.7 version was working fine but now its like this.
the /var/log/mysql/errors.log is empty and these are the /var/log/syslog last lines
Apr 10 13:23:30 server mysqld: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
Apr 10 13:23:30 server mysqld_safe: mysqld from pid file /var/lib/mysql/server.pid ended
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Apr 10 13:24:00 server /etc/init.d/mysql[16277]:
Apr 10 13:24:00 server mysql[15820]: ...fail!
Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
output of mysqld_safe
170410 13:33:28 mysqld_safe Logging to syslog.
170410 13:33:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170410 13:33:28 mysqld_safe mysqld from pid file /var/lib/mysql/server.pid ended
and this is my /etc/mysql/my.cnf and there is no /etc/my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
!includedir /etc/mysql/conf.d/
This problem arrives when your /etc/mysql/mysql.conf.d/mysqld.cnf file is wrongly set. If you recently made changes to this file please revert to the previous one or copy the default one here
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
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 = 0.0.0.0
#
# * 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
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#slow_query_log = 1
#slow_query_log_file = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
#expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
Stop mysql service:
sudo service mysql stop
Remove mysql:
sudo apt-get remove mysql
sudo apt-get purge mysql
Then issue a whereis mysql command in terminal and remove all of the locations that command lists using rm -rf command. For example rm -rf /etc/mysql .
Then reinstall the version of mysql you desire. All should work as expected.
Just check if you db has been given the rights to write the logs give it the logs writing rights and this will get resolved .
1)First remove already installed mysql-server using--
sudo apt-get remove --purge mysql-server mysql-client mysql-common
2)Then clean all files
sudo apt-get autoremove
3)Then install mysql-server --
sudo apt-get remove -f mysql-server
4)Start mysql server--
sudo systemctl start mysql
5)Check status of mysql-server--
systemctl status mysql
I want used "Percona XtraDB Cluster 5.7".
So I installed "Percona XtraDB Cluster" by official guide.
https://www.percona.com/doc/percona-xtradb-cluster/5.7/install/yum.html#yum
But when I add nodes to cluster, my mysql coudn't run.
$ sudo service mysql start
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
$ sudo cat /var/log/messages
...
Jan 13 04:19:25 localhost mysqld_safe: 2017-01-12T19:19:25.588436Z mysqld_safe Skipping wsrep-recover for empty datadir: /var/lib/mysql
Jan 13 04:19:25 localhost mysqld_safe: 2017-01-12T19:19:25.590385Z mysqld_safe Assigning 00000000-0000-0000-0000-000000000000:-1 to wsrep_start_position
Jan 13 04:19:27 localhost mysql-systemd: State transfer in progress, setting sleep higher
Jan 13 04:19:40 localhost mysqld_safe: 2017-01-12T19:19:40.723030Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Jan 13 04:19:47 localhost mysql-systemd: /usr/bin/mysql-systemd: 137 行: kill: (19791) - そのようなプロセスはありません
Jan 13 04:19:47 localhost mysql-systemd: ERROR! mysqld_safe with PID 19791 has already exited: FAILURE
Jan 13 04:19:47 localhost systemd: mysql.service: control process exited, code=exited status=1
Jan 13 04:19:47 localhost mysql-systemd: WARNING: mysql pid file /var/run/mysqld/mysqld.pid empty or not readable
Jan 13 04:19:47 localhost mysql-systemd: ERROR! mysql already dead
Jan 13 04:19:47 localhost systemd: mysql.service: control process exited, code=exited status=2
...
I used centos7 on 3 virtual machine.
And my /etc/my.cnf is default except following code.
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_name=pxc-cluster
wsrep_cluster_address=gcomm://192.168.70.61,192.168.70.62,192.168.70.63
wsrep_node_name=pxc1
wsrep_node_address=192.168.70.61
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:passw0rd
pxc_strict_mode=ENFORCING
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
What should I check?
For the first node, you should bootstrap it, instead of just starting it. On CentOS7 you can do so with:
systemctl start mysql#bootstrap.service
Then, you can go ahead and start nodes 02 and 03 normally:
systemctl start mysql
I'm trying to move the data directory of mysql, here are my steps:
use show variables like 'datadir' to know my datadir is /var/lib/mysql/
cd /var/lib/mysql/
# mv * /home/elderry/db/
gvim /etc/mysql/my.cnf
Add this line in [mysqld] section:
datadir = /home/elderry/db/
# systemctl start mysqld
Job for mysqld.service failed. See 'systemctl status mysqld.service' and 'journalctl -xn' for details.
Then I tried: systemctl status mysqld.service
Result:
mysqld.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
Active: activating (start-post) (Result: exit-code) since Tue 2013-07-30 14:31:53 CST; 13s ago
Process: 14174 ExecStart=/usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Control: 14175 (mysqld-post)
CGroup: name=systemd:/system/mysqld.service
└─control
├─14175 /bin/sh /usr/bin/mysqld-post
└─14293 sleep 1
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [Warning] Can't create test file /home/elderry/db/Kanone.lower-test
Jul 30 14:31:53 Kanone mysqld[14174]: [71B blob data]
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [ERROR] Aborting
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [Note] /usr/bin/mysqld: Shutdown complete
Jul 30 14:31:53 Kanone systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
If I want to start mysql manually: mysql -u root -p
output:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
What shoud I do for now?
It seems you moved the datadir to your home directory. I think that when you start mysqld via your service manager (in your case systemd) it will be started as an unprivileged user (most likely mysql). I strongly doubt that this user has privileges to access the homedir of the user elderry.
So the solution would either be moving your datadir to a more suitable location like /var/lib/mysql and chown this directory to the user under which mysql runs. Or that you give the mysql user privileges that he can acces the homedir of elderry.
When installing MariaDB, it creates user and group mysql automatically that own all data files, so if you move data dir, make sure that all folder, subfoler, files in new data directory are owned by user mysql and group mysql.
Also check if your partition is not full, which was my case.
For an unknown reason, moving the data to another partition did not work either.
So for a quick fix, instead of messing with llvm or gparted, I reduced my /swapfile size.