Database Administrators
Q&A for database professionals who wish to improve their database skills
Latest Questions
3
votes
2
answers
2455
views
Unable to run mariadb in safe mode
When I run following command `mysqld_safe --skip-grant-tables &` I get message `myuser@myvm:~$ 200523 08:24:41 mysqld_safe Logging to syslog. 200523 08:24:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql` After that when I type `mysql` then I get following error: `ERROR 2002...
When I run following command
mysqld_safe --skip-grant-tables &
I get message
`myuser@myvm:~$ 200523 08:24:41 mysqld_safe Logging to syslog.
200523 08:24:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql`
After that when I type mysql
then I get following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
How do I restart mariadb in safe mode to reset root password?
Frank Martin
(451 rep)
May 23, 2020, 12:30 PM
• Last activity: Apr 13, 2025, 09:00 AM
1
votes
1
answers
514
views
Sync of Master Master replication when Primary node comes up MySQL 5.7 Enterprise
I have a Master (say Node A) - Master (Say Node B) ***asynchronous replication*** setup with ***ROW based logging method***. Node A has been setup as Write/Read node and Node B has been setup as Read Node Only. From JBOSS , i am doing switch over that , when A node goes down , all the Write operatio...
I have a Master (say Node A) - Master (Say Node B) ***asynchronous replication*** setup with ***ROW based logging method***.
Node A has been setup as Write/Read node and Node B has been setup as Read Node Only.
From JBOSS , i am doing switch over that , when A node goes down , all the Write operation will get forward to B node and whenever Node A comes up , JBOSS will forward all the Writes to A node.
Now suppose Node A remains down for long time , then all the Writes will go to B node . When A node comes up , it will remain un-sync for a while till it get complete sync with B . While it is getting sync , write operation is also happening on Node A which might result in locking issues as well.
So my question is :
Is there any method in MySQL that when Node A comes up , it will not be accessible by outer application ( like JBOSS , i have mentioned) till it gets complete sync with Node B .
Can we control it via MySQL_Safe mode so that other application can perceive Node A as still down or is there any other method
simplifiedDB
(679 rep)
Apr 10, 2017, 06:02 AM
• Last activity: Apr 6, 2025, 07:06 PM
0
votes
1
answers
76
views
Need clarifications on a few lines of code in the mysqld_safe shell script
I'm trying to develop a tool to check MariaDB option files to identify potential errors. When I was going through the `mysqld_safe` shell script in order to understand how it works, I came across these lines (lines 505 to 536, to be exact): ```sh MY_PWD=`dirname $0` MY_PWD=`cd "$MY_PWD"/.. && pwd` #...
I'm trying to develop a tool to check MariaDB option files to identify potential errors. When I was going through the
mysqld_safe
shell script in order to understand how it works, I came across these lines (lines 505 to 536, to be exact):
MY_PWD=dirname $0
MY_PWD=cd "$MY_PWD"/.. && pwd
# Check for the directories we would expect from a binary release install
if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION"
then
# BASEDIR is already overridden on command line. Do not re-set.
# Use BASEDIR to discover le.
if test -x "$MY_BASEDIR_VERSION/libexec/mariadbd"
then
ledir="$MY_BASEDIR_VERSION/libexec"
elif test -x "$MY_BASEDIR_VERSION/sbin/mariadbd"
then
ledir="$MY_BASEDIR_VERSION/sbin"
else
ledir="$MY_BASEDIR_VERSION/bin"
fi
elif test -x "$MY_PWD/bin/mariadbd"
then
MY_BASEDIR_VERSION="$MY_PWD" # Where bin, share and data are
ledir="$MY_PWD/bin" # Where mysqld is
#Check for the directories we would expect from a source install
elif test -x "$MY_PWD/libexec/mariadbd"
then
MY_BASEDIR_VERSION="$MY_PWD" # Where libexec, share and var are
ledir="$MY_PWD/libexec" # Where mysqld is
elif test -x "$MY_PWD/sbin/mariadbd"
then
MY_BASEDIR_VERSION="$MY_PWD" # Where sbin, share and var are
ledir="$MY_PWD/sbin" # Where mysqld is
# Since we didn't find anything, used the compiled-in defaults
else
MY_BASEDIR_VERSION='/usr'
ledir='/usr/bin'
fi
What confuses me first and foremost is the comment # BASEDIR is already overriden on command line. Do not re-set
. *How* exactly is $MY_BASEDIR_VERSION
set before that line to begin with? The only way (as far as I can tell) for $MY_BASEDIR_VERSION
to be set to a user-provided value (either via command line options or an option file) is via the parse_arguments()
function defined in lines 293 to 384.
parse_arguments() {
for arg do
val=echo "$arg" | sed -e "s;--[^=]*=;;"
case "$arg" in
# these get passed explicitly to mysqld
--basedir=*) MY_BASEDIR_VERSION="$val" ;;
--datadir=*|--data=*) DATADIR="$val" ;;
--pid[-_]file=*) pid_file="$val" ;;
--plugin[-_]dir=*) PLUGIN_DIR="$val" ;;
--user=*) user="$val"; SET_USER=1 ;;
--group=*) group="$val"; SET_USER=1 ;;
--log[-_]basename=*|--hostname=*|--loose[-_]log[-_]basename=*)
pid_file="$val.pid";
err_log_base="$val";
;;
# these might have been set in a [mysqld_safe] section of my.cnf
# they are added to mysqld command line to override settings from my.cnf
--skip[-_]log[-_]error)
err_log=;
skip_err_log=1;
;;
--log[-_]error=*)
err_log="$val";
skip_err_log=0;
;;
--port=*) mysql_tcp_port="$val" ;;
--socket=*) mysql_unix_port="$val" ;;
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
--core[-_]file[-_]size=*) core_file_size="$val" ;;
--ledir=*) ledir="$val" ;;
--malloc[-_]lib=*) set_malloc_lib "$val" ;;
--crash[-_]script=*) crash_script="$val" ;;
--mysqld=*) MYSQLD="$val" ;;
--mysqld[-_]version=*)
if test -n "$val"
then
MYSQLD="mysqld-$val"
PLUGIN_VARIANT="/$val"
else
MYSQLD="mysqld"
fi
;;
--dry[-_]run) dry_run=1 ;;
--nice=*) niceness="$val" ;;
--nowatch|--no[-_]watch|--no[-_]auto[-_]restart) nowatch=1 ;;
--open[-_]files[-_]limit=*) open_files="$val" ;;
--skip[-_]kill[-_]mysqld*) KILL_MYSQLD=0 ;;
--syslog) want_syslog=1 ;;
--skip[-_]syslog) want_syslog=0 ;;
--syslog[-_]tag=*) syslog_tag="$val" ;;
--timezone=*) TZ="$val"; export TZ; ;;
--flush[-_]caches) flush_caches=1 ;;
--numa[-_]interleave) numa_interleave=1 ;;
--wsrep[-_]on)
wsrep_on=1
append_arg_to_args "$arg"
;;
--skip[-_]wsrep[-_]on)
wsrep_on=0
append_arg_to_args "$arg"
;;
--wsrep[-_]on=*)
if echo $val | grep -iq '\(ON\|1\)'; then
wsrep_on=1
else
wsrep_on=0
fi
append_arg_to_args "$arg"
;;
--wsrep[-_]urls=*) wsrep_urls="$val"; ;;
--wsrep[-_]provider=*)
if test -n "$val" && test "$val" != "none"
then
wsrep_restart=1
fi
append_arg_to_args "$arg"
;;
--defaults-group-suffix=*) defaults_group_suffix="$arg" ;;
--help) usage ;;
*)
case "$unrecognized_handling" in
collect) append_arg_to_args "$arg" ;;
complain) log_error "unknown option '$arg'" ;;
esac
esac
done
}
The problem is that parse_arguments()
is first called on line 583 (*after* the aforementioned conditional tests). So how is it possible for $MY_BASEDIR_VERSION
to get overriden on the command line before that?
To me, there are only three conceivable ways for this to occur:
1. mysqld_safe
is re-run somehow after it was first launched (this is possible, but what would be the point in doing so?)
2. The user set the MY_BASEDIR_VERSION
environment variable manually before launching the script.
3. The MY_BASEDIR_VERSION
environment variable is set during MariaDB's installation process.
Having said that, these three possibilities lead to more questions than answers. I have gone through mysqld_safe
's documentation but came up empty. I hope somebody here can provide me with the clarification that I need.
Any insight is much appreciated.
Anthony
(109 rep)
May 9, 2023, 01:06 AM
• Last activity: May 9, 2023, 04:08 AM
0
votes
2
answers
1898
views
How to set malloc-lib in mysql 5.7 in ubuntu 18.04 LTS
I recently installed jemmaloc 3.6.0-11 using `apt-get install libjemalloc1` on my ubuntu server 18.04 The installation were successfull, but when I check using pt-mysql-summary | grep -A5 -i "memory management" I get Memory management library jemalloc is not enabled in mysql config for process with...
I recently installed jemmaloc 3.6.0-11 using
apt-get install libjemalloc1
on my ubuntu server 18.04
The installation were successfull, but when I check using
pt-mysql-summary | grep -A5 -i "memory management"
I get
Memory management library
jemalloc is not enabled in mysql config
for process with id 89539
The End
How I can do this ?
I am using Mysql 5.7.26
Ekkai Imwe
(11 rep)
Aug 8, 2019, 06:27 AM
• Last activity: Aug 16, 2020, 06:05 PM
5
votes
3
answers
19658
views
Cant initialize MySQL. "mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended"
I am doing a fresh install of MySQL on Fedora 22. After I run mysql_install_db I try to start the daemon using mysqld_safe but it does not work. The system says: mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe m...
I am doing a fresh install of MySQL on Fedora 22.
After I run mysql_install_db I try to start the daemon using mysqld_safe but it does not work. The system says:
mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
How do I get this to work?
Here are the mariadb.log contents:
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[Note] /usr/libexec/mysqld (mysqld 10.0.23-MariaDB) starting as process 20443 ...
[Note] InnoDB: Using mutexes to ref count buffer pool pages
[Note] InnoDB: The InnoDB memory heap is disabled
[Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
[Note] InnoDB: Memory barrier is not used
[Note] InnoDB: Compressed tables use zlib 1.2.8
[Note] InnoDB: Using Linux native AIO
[Note] InnoDB: Using CPU crc32 instructions
[Note] InnoDB: Initializing buffer pool, size = 128.0M
[Note] InnoDB: Completed initialization of buffer pool
[ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode
[ERROR] InnoDB: The system tablespace must be writable!
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] mysqld: File '/var/lib/mysql/aria_log_control' not found (Errcode: 13 "Permission denied")
[ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/var/lib/mysql/aria_log_control'
[ERROR] Plugin 'Aria' init function returned error.
[ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
[Note] Plugin 'FEEDBACK' is disabled.
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
[Note] /usr/libexec/mysqld: Shutdown complete
mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
user93897
May 5, 2016, 08:48 AM
• Last activity: Oct 28, 2018, 09:59 PM
1
votes
0
answers
205
views
Enabling Mysql safe updates
I'm using mysql 5.5 and trying to enable Mysql safe update on my.cnf file [mysq] --i-am-a-dummy -safe-update it got reflected on root mysql login. > SHOW VARIABLES LIKE 'sql_safe_updates' is ON But When I tried to use mysql user, the -safe-update is not working and also > SHOW VARIABLES LIKE 'sql_sa...
I'm using mysql 5.5 and trying to enable Mysql safe update on my.cnf file
[mysq]
--i-am-a-dummy
-safe-update
it got reflected on root mysql login.
> SHOW VARIABLES LIKE 'sql_safe_updates' is ON
But When I tried to use mysql user, the -safe-update is not working and also
> SHOW VARIABLES LIKE 'sql_safe_updates' show it is OFF.
How to enable mysql safe update for all users permanently?
adminz
(123 rep)
Jul 18, 2018, 05:41 PM
2
votes
1
answers
2419
views
Is there anyway that I can manually create a PID for the MySQL instance?
I am running MySQL on a linux server. I have taken a copy-back mysql enterprise backup from another linux full backup. Ever sense then I have had problems getting MySQL to start. The problem is that MySQL is not updating the PID file, it's not even create a PID file. Is there anyway that I can manua...
I am running MySQL on a linux server. I have taken a copy-back mysql enterprise backup from another linux full backup. Ever sense then I have had problems getting MySQL to start. The problem is that MySQL is not updating the PID file, it's not even create a PID file. Is there anyway that I can manually create a PID for the MySQL instance?
One work around that I have been able to implement is the using the mysql-debugger which creates its own pid, but when I stop the debugger it still won't create/update the PID file.
asdf
(99 rep)
Apr 20, 2016, 02:56 PM
• Last activity: Apr 20, 2016, 03:45 PM
2
votes
2
answers
475
views
Mysql hand machine due to high load average and CPU
[![Snapshot of High Load average][1]][1] [1]: https://i.sstatic.net/Xe8fz.jpg Mysql is used by only one application which only fire query periodically. When i restart server,It run smooth for period of time. and then crash the whole server. My my.cnf file [mysqld] datadir=/var/lib/mysql socket=/var/...

Brijesh Mistry
(21 rep)
Nov 25, 2015, 01:29 PM
• Last activity: Dec 14, 2015, 02:26 PM
3
votes
1
answers
2983
views
MySQL: mysqld_safe options
Is there a way to specify [these options][1] in configuration file? I've tried to add them into `[mysqld_safe]` section but it doesn't work: [mysqld_safe] numa-interleave = 1 flush-caches = 1 - # ps -ww -lfC mysqld_safe F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 4 S root 17180 1 0 80...
Is there a way to specify these options in configuration file?
I've tried to add them into
[mysqld_safe]
section but it doesn't work:
[mysqld_safe]
numa-interleave = 1
flush-caches = 1
-
# ps -ww -lfC mysqld_safe
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 17180 1 0 80 0 - 26549 wait 15:06 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/mysql.pid
Please note that I'm using Percona server 5.5.30-30.2
**EDIT: 28 Aug 2013 - 08:34:**
Unfortunately I can't find this line in /etc/init.d/mysql
:
# grep -n "interleave" < /etc/init.d/mysql
# echo $?
1
I'm able to manually invoke these options:
mysqld_safe --datadir=/mnt/data/mysql --pid-file=/mnt/data/mysql/db3.improve.pid --numa-interleave --flush-caches
but with option file there is still default
policy
# cat /proc/$(pidof mysqld)/numa_maps | cut -d ' ' -f 2 | uniq
default
There must be some way other than hard coding these options into init
script or manually staring MySQL daemon...
**EDIT: 29 Aug 2013 - 08:38:**
I've just tested it with Percona Server 5.5.28-29.1.
I still don't see numa
related entries in /etc/init.d/mysql
however there are in mysqld_safe
script:
# grep -n "interleave" /usr/bin/mysqld_safe
21:numa_interleave=0
67: --numa-interleave Run mysqld with its memory interleaved
215: --numa-interleave) numa_interleave=1 ;;
777:# Set mysqld's memory interleave policy.
780:if true && test $numa_interleave -eq 1
785: log_error "numactl command not found, required for --numa-interleave"
788: elif ! numactl --interleave=all true
794: cmd="$cmd numactl --interleave=all"
795:elif test $numa_interleave -eq 1
797: log_error "--numa-interleave is not supported on this platform"
I've tested other options like nice
, open_files_limit
and they work fine so it looks like the only option is to hard-code it into init
script
HTF
(451 rep)
Aug 27, 2013, 02:59 PM
• Last activity: Aug 29, 2013, 07:39 AM
2
votes
1
answers
2696
views
InnoDB: Error: pthread_create returned 12
have installed MySQL in a particular folder. I was able to run the server and create accounts, databases etc. However, now whenever I try to start the server, I get an error: $ mysqld_safe --defaults-file=mysql.cnf & [1] 2002 [compute-0-5 /amber2/scratch/myname/mysql]$ 130725 17:56:24 mysqld_safe Lo...
have installed MySQL in a particular folder. I was able to run the server and create accounts, databases etc. However, now whenever I try to start the server, I get an error:
$ mysqld_safe --defaults-file=mysql.cnf &
2002
[compute-0-5 /amber2/scratch/myname/mysql]$ 130725 17:56:24 mysqld_safe Logging to '/amber2/scratch/myname/mysql/data/compute-0-5.local.err'.
130725 17:56:24 mysqld_safe Starting mysqld daemon with databases from /amber2/scratch/myname/mysql/data
130725 17:56:25 mysqld_safe mysqld from pid file /amber2/scratch/myname/mysql/data/compute-0-5.local.pid ended
+ Done mysqld_safe --defaults-file=mysql.cnf
In the error file inside the data folder:
130725 17:17:53 mysqld_safe Starting mysqld daemon with databases from /amber2/scratch/myname/mysql/data
2013-07-25 17:17:54 0 [Warning] option 'read_buffer_size': unsigned value 2147483648 adjusted to 2147479552
2013-07-25 17:17:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-07-25 17:17:54 28189 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2013-07-25 17:17:54 28189 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)
2013-07-25 17:17:54 28189 [Note] Plugin 'FEDERATED' is disabled.
2013-07-25 17:17:54 28189 [Note] InnoDB: The InnoDB memory heap is disabled
2013-07-25 17:17:54 28189 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-07-25 17:17:54 28189 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-07-25 17:17:54 28189 [Note] InnoDB: Using Linux native AIO
2013-07-25 17:17:54 28189 [Note] InnoDB: Not using CPU crc32 instructions
2013-07-25 17:17:54 28189 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-07-25 17:17:54 28189 [Note] InnoDB: Completed initialization of buffer pool
2013-07-25 17:17:54 28189 [Note] InnoDB: Highest supported file format is Barracuda.
InnoDB: Error: pthread_create returned 12
130725 17:17:55 mysqld_safe mysqld from pid file /amber2/scratch/myname/mysql/data/compute-0-18.local.pid ended
But why am I getting the pthread_create error 12? It seems this is related to not enough space. On the device where the mysql folder (/amnber2//scratch/myname/mysql) resides, I do have space:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 49G 5.0G 41G 11% /
...
10.255.255.46:/export/scratch
15T 11T 4.2T 72% /amber2/scratch
I also have a few gigs in my home directory quota
$ quota -v
Disk quotas for user myname (uid 41222):
Filesystem blocks quota limit grace files quota limit grace
10.255.255.45:/export/ncms
22986221 26214400 26214400 0 0 0
10.255.255.46:/export/scratch
7321108 0 0 0 0 0
i.e., I am using 22G out of 25G:
$ du -sh ~/.
22G /home/ncms/myname/.
I also have free memory:
$ free -mg
total used free shared buffers cached
Mem: 62 41 21 0 0 28
-/+ buffers/cache: 12 49
Swap: 64 13 51
In my mysql configuration file:
myisam_sort_buffer_size=4G
myisam_max_sort_file_size=200G
read_buffer_size=2G
So why am I getting the error
pthread_create
error while starting the server?
highBandWidth
(163 rep)
Jul 25, 2013, 10:17 PM
• Last activity: Jul 25, 2013, 11:00 PM
2
votes
1
answers
11205
views
mysqld_safe version different than mysqld?
Is it a problem that mysqld socket has a different version than the mysqld server? I noticed this in my mysqld log during startup 120420 19:30:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 120420 19:30:06 InnoDB: Initializing buffer pool, size = 8.0M 120420 19:30:06 InnoDB...
Is it a problem that mysqld socket has a different version than the mysqld server?
I noticed this in my mysqld log during startup
120420 19:30:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120420 19:30:06 InnoDB: Initializing buffer pool, size = 8.0M
120420 19:30:06 InnoDB: Completed initialization of buffer pool
120420 19:30:06 InnoDB: Started; log sequence number 0 44233
120420 19:30:06 [Note] Event Scheduler: Loaded 0 events
120420 19:30:06 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.61' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
Yet, when I show variables I get this
> SHOW VARIABLES LIKE "%version%";
+-------------------------+-------------------------------------------+
| Variable_name | Value |
+-------------------------+-------------------------------------------+
| innodb_version | 5.5.30 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.30-cll |
| version_comment | MySQL Community Server (GPL) by Atomicorp |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+-------------------------------------------+
7 rows in set (0.00 sec)
Based on golimar's questions I ran a
> ps aux
and I see this
> mysql 633 31.4 33.5 11942788 5452172 ? SNl 08:18 101:31
> /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql
> --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/host.reviewcritical.com.err --open-files-limit=4096 --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock --port=3306
>
> root 32674 0.0 0.0 108292 1576 ? SN 08:18 0:00
> /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql
> --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
giorgio79
(1407 rep)
Mar 5, 2013, 10:36 AM
• Last activity: Mar 6, 2013, 08:05 PM
Showing page 1 of 11 total questions