When I run apt-get install percona-server-server-5.6, the percona server gets installed and started. The processes running (ps -ef | grep mysql) look like this (HOSTNAME is obfuscated):
root 14309 1 0 23:54 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/HOSTNAME.pid
mysql 14413 14309 3 23:54 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/HOSTNAME.err --pid-file=/var/lib/mysql/HOSTNAME.pid
My question is where is this default PID file coming from? There is no my.cnf file under /etc/mysql and the my.cnf file under /usr doesn't have any of this information. This is causing a problem ebcause when I deploy my configuration file and try to restart the server, the box obviously doesn't work. I believe the correct default for the PID file is /var/run/mysqld/mysqld.pid.
Looks like this is being set in the init mysql file.
Related
Ok, i'm following official Mysql docs to enable encryption on a mysql database on docker:
Using the keyring_file File-Based Plugin
Keyring Plugin Installation
keyring_file_data
So here's what i've done:
added early-plugin-load and keyring_file_data to /etc/mysql/my.cnf (i used echo stuff >> file since mysql docker image has no text editor), so now it is:
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Custom config should go here
!includedir /etc/mysql/conf.d/
early-plugin-load=keyring_file.so
keyring_file_data=/usr/local/mysql/mysql-keyring/keyring
created keyring file with
cd /usr/local/mysql
mkdir mysql-keyring
chmod 750 mysql-keyring
chown mysql mysql-keyring
chgrp mysql mysql-keyring
restarted container to restart mysql
connected to mysql and checked plugin availability (whith no luck) with
mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE 'keyring%';
Checked the logs for errors:
2020-03-15T12:30:08.669015Z 0 [ERROR] [MY-011370] [Server] Plugin keyring_file reported: 'File '/usr/local/mysql/mysql-keyring/keyring' not found (OS errno 20 - Not a directory)'
2020-03-15T12:30:08.669036Z 0 [ERROR] [MY-011355] [Server] Plugin keyring_file reported: 'keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file or keyring file can be created in the specified location. The keyring_file will stay unusable until correct path to the keyring file gets provided'
2020-03-15T12:30:08.669053Z 0 [ERROR] [MY-010202] [Server] Plugin 'keyring_file' init function returned error.
So it look like that i correctly enabled the plugin, but something is wrong with the file.
Am i missing some steps?
keyring file
root#8c3670db35d4:/# ls -la /usr/local/mysql/mysql-keyring/
total 8
drwxr-s--- 2 mysql mysql 4096 Mar 15 12:34 .
drwxr-sr-x 3 root staff 4096 Mar 15 12:33 ..
-rw-r----- 1 mysql mysql 0 Mar 15 12:34 keyring
Are you sure you created the keyring file correctly inside the container ? This is how I was able to achieve the above with a correctly crafted Dockerfile.
Create a folder for your image project (use whatever folder you like)
mkdir /tmp/testMysqlKeyring
cd /tmp/testMysqlKeyring
Create a mysql keyring dropin configuration file keyring.cnf with the following content:
[mysqld]
early-plugin-load=keyring_file.so
keyring_file_data=/usr/local/mysql/mysql-keyring/keyring
Create a Dockerfile with the following content
FROM mysql:8
# Place the dropin config file in the relevant folder
COPY keyring.cnf /etc/mysql/conf.d/
# Create the keyring folder and adapt perms
RUN mkdir -p /usr/local/mysql/mysql-keyring && \
chmod 750 /usr/local/mysql/mysql-keyring && \
chown mysql.mysql /usr/local/mysql/mysql-keyring
Build image from the above configuration:
docker build -t file_keyringed_mysql:latest .
Run a container from that image (you will adapt with your exact volumes and environment later...)
docker run -d --rm --name my_keyring_test -e MYSQL_ALLOW_EMPTY_PASSWORD=true file_keyringed_mysql:latest
Check that plugin is correctly installed inside the container
$ docker exec my_keyring_test mysql -e "SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'keyring%';"
PLUGIN_NAME PLUGIN_STATUS
keyring_file ACTIVE
I have mysql installed on centos 7 on office, I expected it would have configuiration file located at /etc/mysql/my.cnf but I spotted directly under /etc.
is it possible to find out using the mysql cli the configuration file in use ?
Please refer here for details. The article discusses the default configuration file scan order.
But you could also specify the --defaults-file when starting mysql, please use ps -ef |grep mysql or similar command to check. On my machine, the output like this(suse12):
ps -ef |grep mysql
mysql 968 1 0 Apr27 ? 00:46:36 ./mysqld --defaults-file=/export/home/mysql/mysql-8.0.11/my.cnf --user=mysql
root 71136 65599 0 11:45 pts/0 00:00:00 grep --color=auto mysql
I am able to connect to mysql database and query it. But, I am NOT able to find the socket file.
$ps -ef|grep mysql
mysql 31408 30874 0 18:46 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/mysql/admin/ofile/TEST1.cnf
mysql 31959 31408 0 18:46 pts/1 00:00:01 /usr/sbin/mysqld --defaults- file=/mysql/admin/ofile/TEST1.cnf --basedir=/usr -- datadir=/mysql01data/TEST1/data --plugin-dir=/usr/lib64/mysql/plugin --log- error=/mysql/admin/TEST1/errors/mysqld_safe.err --pid- file=/mysql/admin/TEST1/run/mysqld_safe.pid
Here is my socket file entry in TEST1.cnf:
$ cat /mysql/admin/ofile/TEST1.cnf|grep sock
socket = /mysql/admin/TEST1/run/TEST1.sock
The corresponding directory only contains pid file. There is no socket file.
-sh-4.1$ cd /mysql/admin/TEST1/run
-sh-4.1$ ls -lrt
total 4
-rw-rw---- 1 mysql mysql 6 Apr 29 18:46 mysqld_safe.pid
This is the MySQL 5.6 version I installed through RPM's on RHEL 6.5. I have my old custom scripts which uses socket file to connect to the database.
So, I am wondering how I can use the socket file to connect to the database? Why the socket file is not created by default?
The socket file for a running instance of MySQL Server should be something that can be found with this shell command:
sudo lsof -a -U -p $(pgrep -d, -f /path/to/your/running/mysqld)
One possible cause of being unable to find the socket file would be if it had been deleted after the server was started. In that case the above command should work, and show something like (deleted) after the path.
That was my original assumption on this question... but here the issue was a configuration oversight. The "defaults file," commonly called my.cnf contains multiple sections. The [client] section configures client utilities, like mysql and mysqldump, while the [mysqld] section configures the server daemon. If the socket directive isn't in the appropriate section, the server (and/or client utilities) will look in the location compiled in by default, with /tmp/mysql.sock or /var/lib/mysql/mysql.sock being a couple of examples of common default locations.
I have CentOS 6.4 with NGINX.
When I try to start/stop/restart mysql server (/etc/init.d/mysqld restart) I get this error:
MySQL server PID file could not be found! [FAILED]
Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/mysqld.pid).
What can I do to solve this problem?
Thanks!
I got the same error on a CentOS 6.3 where I upgraded MySQL to 5.6.14 but I kept the old my.cnf file. After upgrade, MySQL did not start anymore, giving me the same error as you described.
The problem was that I had this setting in my.cnf:
table_cache=2048
According to this link table_cache renamed table_open_cache..
"Seem like in 5.5 the system variable table_cache was renamed
table_open_cache..
In 5.6 mysqld fails if it finds an unknown variable
this means that upgrades from versions earlier than 5.5 can have
problems if table_cache is specified in my.cnf."
After I changed the above line to
table_open_cache=2048
MySQL started perfectly.
So, in the case you have MySQL 5.5+ (and maybe an older my.cnf), I suggest you to do the following:
remove my.cnf from /etc folder and try to start MySQL
if MySQL starts, the the problem is in my.cnf. Comment/uncomment all the settings one by one in order to see which is causing the problem.
Hope this helps.
I upgraded my Mac OS to 10.9.3 and encountered the above problem on mysql.server restart
The following fixed my problem
sudo chmod -R o+rwx /usr/local/var/mysql/
sudo chown -R mysql /usr/local/var/mysql/
sudo mysql.server restart
First of all make sure that which folder/file is not exist in /var/run/mysqld/mysqld.pid
if dir not exists then create it as:
sudo mkdir -p /var/run/mysqld/
if mysqld.pid is not exists then create it as:
sudo touch /var/run/mysqld/mysqld.pid
change ownership as:
sudo chown mysql:mysql -R /var/run/mysqld
chmod 775 -R /var/run/mysqld
restart mysql service
sudo service mysql restart
I find that sometimes MySQL processes are still running. Certainly this was the case on my OS X Yosemite system so use the following command to find any processes that show up with MySQL in the name:
ps aux | grep mysql
Then kill them using the command
sudo kill -9 PID, replacing PID with the offending process ID.
Check if there is a lock.
/etc/init.d/mysql status
If the OS says that there is a lock, something like:
ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
remove that lock file and restart.
I found this worked....
# ps aux | grep mysql
root 3668 0.0 0.0 11432 1240 ? S 2014 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/db/data01 --pid-file=/var/lib/mysql/mysql.pid
mysql 5303 0.1 0.4 1964748 12368 ? S<l 2014 1663:35 /usr/sbin/mysqld --basedir=/usr --datadir=/db/data01 --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/db/logs01/mysql-error.err --open-files-limit=8192 --pid-file=/var/lib/mysql/mysql.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root 12369 0.0 0.0 6376 680 pts/0 S+ 09:05 0:00 grep mysql
# kill -9 3668 5303
# rm /var/lock/subsys/mysql rm: remove regular empty file `/var/lock/subsys/mysql'? y
# service mysql start Starting MySQL (Percona Server).. SUCCESS!
I have freshly installed xampp-linux-1.8.1 on my Ubuntu 12.04 (Mint 13 maya) Operating system.
When run lampp, I get :
/opt/lampp/lampp start
Starting XAMPP for Linux 1.8.1...
XAMPP: XAMPP-Apache is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: XAMPP-ProFTPD is already running.
XAMPP for Linux started.
In the : localhost/xampp/
MySQL DataBase is Deactivated !!!
ps -aux | grep 'mysql'
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html mysql 3159 0.0 0.9 316264 31880 ? Ssl 16:48 0:00 /usr/sbin/mysqld
root 4745 0.0 0.0 4648 840 pts/5 S+ 17:02 0:00 grep --color=auto mysql
When I tried to stop /usr/sbin/mysqld but it can't be stopped with this command !!!
/usr/sbin/mysqld stop
Please I need Help, Thanks.
i've resolved the issue in this way:
sudo chmod -R 777 /opt/lampp
sudo chown -hR nobody /opt/lampp
sudo chmod -R 755 /opt/lampp
then stop other mysqld running with:
sudo service mysql stop
Also had this issue, after troubleshooting for almost 2 hours I found that it was because of other Apache and MySQL packages also running on my system. Removed all Apache and MySQL packages and reinstalled XAMPP again. Success.