Can't create/write to file (Errcode: 30) - mysql

I recently had an error on my mysql database and against better judgement (I'm not a server guy at all) I tried to resolve it through googling and changing server stuff...
So first off, mysql was showing this error "Can't create/write to file (Errcode: 30)"
I think I followed these answers which ended up causing more problems:
MySQL: Can't create/write to file '/tmp/#sql_3c6_0.MYI' (Errcode: 2) - What does it even mean?
http://nixcraft.com/showthread.php/14260-ERROR-1-(HY000)-Can-t-create-write-to-file-tmp-sql_9f3_0-MYI-(Errcode-13)
Only looking back, I see that these googled answers have different error codes, not "30"
Here is the log of the actions I did, causing the server to fail even more at the end (mysqld won't even restart up now)
[root#xxx ~]# /usr/sbin/lsof /tmp
[root#xxx ~]# /bin/umount -l /tmp
umount: /tmp: not mounted
[root#xxx ~]# /bin/umount -l /var/tmp
umount: /var/tmp: not mounted
[root#xxx ~]# cat /etc/my.cnf | grep tmpdir
[root#xxx ~]#
[root#xxx ~]# cat /etc/my.cnf | grep tmpdir
[root#xxx ~]# chown root:root /tmp
chown: changing ownership of `/tmp': Read-only file system
[root#xxx ~]# chmod 1777 /tmp
chmod: changing permissions of `/tmp': Read-only file system
[root#xxx ~]# /etc/init.d/mysqld restart
rm: cannot remove `/var/lock/subsys/mysqld': Read-only file system
rm: cannot remove `/var/lib/mysql/mysql.sock': Read-only file system
Stopping mysqld: [ OK ]
Starting mysqld: [FAILED]
[root#xxx ~]# chmod 777 /var/lock/subsys/mysqld
chmod: changing permissions of `/var/lock/subsys/mysqld': Read-only file system
[root#xxx ~]# chmod 777 /var/lib/mysql/mysql.sock
chmod: changing permissions of `/var/lib/mysql/mysql.sock': Read-only file system
[root#xxx ~]# /etc/init.d/mysqld restart
Stopping mysqld: [FAILED]
Starting mysqld: [FAILED]
[root#xxx ~]# /etc/init.d/mysqld restart
Stopping mysqld: [FAILED]
Starting mysqld: [FAILED]
[root#xxx ~]#
From the links listed above, you'll see that I tried following things such as
"check mysql config : my.cnf
cat /etc/my.cnf | grep tmpdir
I can't see anything in my my.cnf
add tmpdir=/tmp to my.cnf under [mysqld]
restart web/app and mysql server
/etc/init.d/mysqld restart"
" chown root:root /tmp
chmod 1777 /tmp
/etc/init.d/mysqld restart"
But yeah, I haven't touched it since because I think I would just be messing it up even more.
Server running is CentOS 6.5 64bit LAMP
Let me know if anyone could shed some insight or if I should provide anymore information. Thanks! Much appreciated.

Related

Job for mysqld.service failed See "systemctl status mysqld.service"

Console says
[root#ip-172-31-18-2 mysql]# service mysqld start
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with an error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
mysqld.service
[root#ip-172-31-18-2 mysql]# systemctl status mysqld.service
● mysqld.service - SYSV: MySQL database server.
Loaded: loaded (/etc/rc.d/init.d/mysqld)
Active: failed (Result: exit-code) since Sat 2017-02-18 20:59:17 IST; 36s ago
Docs: man:systemd-sysv-generator(8)
Process: 9925 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)
Feb 18 20:59:16 ip-172-31-18-2.ap-southeast-1.compute.internal systemd[1]: Starting SYSV: MySQL database server....
Feb 18 20:59:17 ip-172-31-18-2.ap-southeast-1.compute.internal mysqld[9925]: MySQL Daemon failed to start.
Feb 18 20:59:17 ip-172-31-18-2.ap-southeast-1.compute.internal mysqld[9925]: Starting mysqld: [FAILED]
Feb 18 20:59:17 ip-172-31-18-2.ap-southeast-1.compute.internal systemd[1]: mysqld.service: control process exited, code=exited status=1
Feb 18 20:59:17 ip-172-31-18-2.ap-southeast-1.compute.internal systemd[1]: Failed to start SYSV: MySQL database server..
Feb 18 20:59:17 ip-172-31-18-2.ap-southeast-1.compute.internal systemd[1]: Unit mysqld.service entered failed state.
Feb 18 20:59:17 ip-172-31-18-2.ap-southeast-1.compute.internal systemd[1]: mysqld.service failed.
What I have tried until now:
mysqld_safe --defaults-file=/etc/my.cf
chown -R mysql:mysql /var/lib/mysql
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
systemctl restart systemd-logind
rebooted the server
Still no luck.
my.cnf file
# 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 a 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
This amazingly worked.
/etc/init.d/mysql stop
service mysql stop
killall -KILL mysql mysqld_safe mysqld
/etc/init.d/mysql start
service mysql start
I had the same error, the problem was because I no longer had disk space.
to check the space run this:
$ df -h
Then delete some files that you didn't need.
After this commands:
service mysql start
systemctl status mysql.service
mysql -u root -p
After entering with the root password verify that the mysql service was active
I met this problem today, and fix it with bellowed steps.
1, Check the log file /var/log/mysqld.log
tail -f /var/log/mysqld.log
2017-03-14T07:06:53.374603Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2017-03-14T07:06:53.374614Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory
The log says that there isn't a file or directory /var/run/mysqld/mysqld.pid
2, Create the directory /var/run/mysqld
mkdir -p /var/run/mysqld/
3, Start the mysqld again service mysqld start, but still fail, check the log again /var/log/mysqld.log
2017-03-14T07:14:22.967667Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)
2017-03-14T07:14:22.967678Z 0 [ERROR] Can't start server: can't create PID file: Permission denied
It saids permission denied.
4, Grant the permission to mysql
chown mysql.mysql /var/run/mysqld/
5, Restart the mysqld
# service mysqld restart
Restarting mysqld (via systemctl): [ OK ]
These are the steps I took to correct this:
Back up your my.cnf file in /etc/mysql and remove or rename it
sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
Remove the folder /etc/mysql/mysql.conf.d/ using
sudo rm -r /etc/mysql/mysql.conf.d/
Verify you don't have a my.cnf file stashed somewhere else (I did in my home dir!) or in /etc/alternatives/my.cnf use
sudo find / -name my.cnf
Now reinstall every thing
sudo apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7
sudo apt install mysql-server
In case your syslog shows an error like "mysqld: Can't read dir of '/etc/mysql/conf.d/'" create a symbolic link:
sudo ln -s /etc/mysql/mysql.conf.d /etc/mysql/conf.d
Then the service should be able to start with sudo service mysql start.
I hope it work
In my particular case, the error was appearing due to missing /var/log/mysql with mysql-server package 5.7.21-1 on Debian-based Linux distro. Having ran strace and sudo /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid ( which is what the systemd service actually runs), it became apparent that the issue was due to this:
2019-01-01T09:09:22.102568Z 0 [ERROR] Could not open file '/var/log/mysql/error.log' for error logging: No such file or directory
I've recently removed contents of several directories in /var/log so it was no surprise. The solution was to create the directory and make it owned by mysql user as in
$ sudo mkdir /var/log/mysql
$ sudo chown -R mysql:mysql /var/log/mysql
Having done that I've happily logged in via sudo mysql -u root and greeted with the old and familiar mysql> prompt
if your problem not fix, you can try check more problem.
maybe mysql crash , like this :
you can check log in
sudo cat /var/log/mysql/error.log
or you check
sudo ls /var/crash
try
sudo chown mysql:mysql -R /var/lib/mysql
then start your mysql service
systemctl start mysqld
the issue is with the "/etc/mysql/my.cnf". this file must be modified by other libraries that you installed. this is how it originally should look like:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
I was also facing same issue .
root#*******:/root >mysql -uroot -password
mysql: [Warning] Using a password on the command line interface can be
insecure. ERROR 2002 (HY000): Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2)
I found ROOT FS was also full and then I killed below lock session .
root#**********:/var/lib/mysql >ls -ltr
total 0
-rw------- 1 mysql mysql 0 Sep 9 06:41 mysql.sock.lock
Finally Issue solved .
open my.cnf and copy the log-error path
then check the permission for the copied log file using
$ ls -l /var/log/mysql.log
if any log file permission may changed from mysql:mysql, please change the file permission to
$ chown -R mysql:mysql /var/log/mysql.log
then restart the mysql server
$ service mysql restart || systemctl restart mysqld
note: this kind of errors formed by the permission issues. all the mysql service start commands using the log file for writing the status of mysql. If the permission has been changed, the service can't be write anything into the log files. If it happens it will stopped to run the service
remove any command of "secure_file_priv" in /etc/mysql/my.cnf and restart mysql.
If you want to use a file in mysql, copy those files to the main folder.
The main folder is obtained this way : SHOW VARIABLES LIKE "secure_file_priv";
You can purge all mysql-related packages and reinstall them with the following commands:
PACKAGES="mysql-server mysql-community-server mysql-community-server-core mysql-client mysql-client mysql-community-client mysql-community-client-core mysql-common mysql-community-client-plugins php-mysql"
apt purge $PACKAGES
echo "any remaining installed packages:"
dpkg -l|grep ii|grep mysql
apt install --reinstall mysql-common
apt install $PACKAGES
If there are any remaining packages (apart from mysql-core), add those to your list
Backup your config or data and reinstall mysql
sudo apt remove --purge mysql-server
sudo apt purge mysql-server
sudo apt autoremove
sudo apt autoclean
sudo apt remove dbconfig-mysql
sudo apt-get remove --purge mysql* -y
sudo apt-get autoremove -y
sudo apt-get autoclean
Then install it again.
That works here.
i have got the same "systemctl status mysql.service" and "journalctl -xe" for details. ERROR.
after repeated deinstallation and installation does not work at all.
but this one work well> https://linuxtut.com/en/5a5b0f46620ae1b27b10/
you just need to remove everything from my.cnf file except [mysqld] and start the server. this really work. but you might not have the password for root in that case skip-grant-tables and restart server in safe mode and use mysql and
update mysql.user set authentication_string=null where user='root' and then can alter user 'root'#'localhost' identified by 'your_$$new_99pwd#';
then login to secure mode and then you can create new user.
Also don't forget to check on your docker containers, for me it was my docker has mysql running on the background.
Connect to the server using SSH.
Stop the affected MySQL service and the service plesk-web-socket to prevent it from attempting to start MySQL:
service mysql stop || service mariadb stop && service plesk-web-socket stop
Back up all the MySQL data storage files. By default, they are located in the directory /var/lib/mysql/.
For example:
cp -a /var/lib/mysql /root/mysql_backup
Add the parameter innodb_force_recovery to the section [mysqld] of the MySQL configuration file. This option allows starting MySQL service in the recovery mode and try creating dumps of databases.
For example:
vi /etc/my.cnf
[mysqld]
innodb_force_recovery = 2
Start the MySQL service.
after having tested several solutions without success, the one that finally worked is the following:
you can load the default configuration of your apache server
sudo a2ensite 000-default.conf
sudo a2dissite my.conf
systemctl reload apache2
then reload the configuration for your website
sudo a2ensite my.conf
sudo a2dissite 000-default.conf
systemctl reload apache2
I had the same issue and after hours the solution was for me:
Open this file nano /etc/mysql/my.cnf
#I use mysql service if you use mysqld service, type mysqld instead of mysql
[mysql]
innodb_force_recovery = 1
Had the same problem. Solved as given below.
Use command :
sudo tail -f /var/log/messages|grep -i mysql
to check if SELinux policy is causing the issue. If so, first check if SELinux policy is enabled using command #sestatus. If it shows enabled, then disable it.
To disable:
# vi /etc/sysconfig/selinux
change 'SELINUX=enforcing' to 'SELINUX=disabled'
restart linux
check with sestatus and it should show "disabled"
Uninstall and reinstall mysql. It should be working.

cannot touch `/var/log/mysqld.log': Permission denied

i have reinstalled mysql server in cent OS RHEL5.5 , Im getting the following error
touch: cannot touch `/var/log/mysqld.log': Permission denied
chown: changing ownership of `/var/log/mysqld.log': Operation not permitted
chmod: changing permissions of `/var/log/mysqld.log': Operation not permitted
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
I have checked the permissions for log files , its having correct permissions as mysql user
-rw-r----- 1 mysql mysql 5931 Mar 9 04:36 mysqld.log
Please let me know the issue on this and how to solve it.
Thanks
Ok. I have solved the issue,
$ /usr/libexec/mysqld --skip-grant &
[1] 5388
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
150312 10:03:28 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.95' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
$ rm -rf /var/lib/mysql/ib_logfile0
$ rm -rf /var/lib/mysql/ib_logfile1
$ ls -l /var/lib/mysql
i have removed the log files and restart the mysql server.
Thanks
The workaround is:
$ sudo touch /var/log/mysqld.log
$ sudo chown mysql:mysql /var/log/mysqld.log
$ sudo chcon system_u:object_r:mysqld_log_t:s0 /var/log/mysqld.log
In my case, this happened to me after downgrading an AWS EC2 instance. The error was as follows:
$ service mysqld start
touch: cannot touch ‘/var/log/mysqld.log’: Permission denied
chown: changing ownership of ‘/var/log/mysqld.log’: Operation not permitted
chmod: changing permissions of ‘/var/log/mysqld.log’: Operation not permitted
chown: changing ownership of ‘/var/lib/mysql’: Operation not permitted
chmod: changing permissions of ‘/var/lib/mysql’: Operation not permitted
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
Turns out the issue was the new downgraded VM didn't have enough memory as MySQL was trying to reserve.
Updating the value reserved for InnoDB on etc/my.cnf solved the issue:
innodb_buffer_pool_size=4G
No other changes on the file system permissions were needed.
In my case, there is problem with ubuntu apparmor.
Solution:
Edit mysqld profiles (usually in /etc/apparmor.d/usr.sbin.mysqld) and make sure you have:
/var/log/mysqld.log rw,
systemctl reload apparmor
touch /var/log/mysqld.log
chown mysql:mysql /var/log/mysqld.log
chmod 0644 /var/log/mysqld.log
systemctl restart mysql

MySQL installation from deb, permissions issues

I am trying to install MySQL on ubuntu 14.04 from the deb packages. I am having trouble starting the mysql server, it looks like a permissions problem. I followed the steps outlined here. Downloaded/untarred/installed deb tar bundle.
sudo apt-get install libaio1
tar -xvf mysql-server_5.7.4-m14-2ubuntu14.04_amd64.deb-bundle.tar
md5sum mysql-server_5.7.4-m14-2ubuntu14.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-server_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.4-m14-2ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient18_5.7.4-m14-2ubuntu14.04_amd64.deb
Here is where the files are installed on my system:
All configuration files (like my.cnf) are under /etc.
All binaries, libraries, headers, etc., are under /usr.
The data directory is under /var.
Following these instructions
I create a mysql group and user:
groupadd mysql
useradd -r -g mysql mysql
I change the ownership of mysql scripts to mysql (as per the instructions, but doubt this is necesssary)
cd /usr/bin
sudo chown mysql mysq*
sudo chgrp mysql mysq*
I run mysql_install_db to set up grant tables
sudo mysql_install_db --user=mysql
I switch back to root the ownership and group of mysql scripts.
cd /usr/bin
sudo chown root mysq*
sudo chgrp root mysq*
I change the ownership and group of /data to mysql. Location is /var/lib/mysql
cd /var/lib
ls -l mysql
total 122896
-rw-rw-rw- 1 mysql mysql 56 Jul 26 10:17 auto.cnf
-rw-rw-rw- 1 mysql mysql 12582912 Jul 26 10:17 ibdata1
-rw-rw-rw- 1 mysql mysql 50331648 Jul 26 10:17 ib_logfile0
-rw-rw-rw- 1 mysql mysql 50331648 Jul 24 17:36 ib_logfile1
-rw-rw---- 1 mysql mysql 12582912 Jul 26 10:17 ibtmp1
drwxrwxrw- 2 mysql mysql 4096 Jul 24 17:36 mysql
drwxrw-rw- 2 mysql mysql 4096 Jul 24 17:36 performance_schema
drwxrw-rw- 2 mysql mysql 4096 Jul 24 17:36 test
Now, when I try to start the mysql server, I get permission errors:
mysqld_safe --user=mysql &
[4] 5680
/var/lib$ 140727 00:42:17 mysqld_safe Logging to '/var/log/mysql/error.log'.
cat: /var/run/mysqld/mysqld.pid: Permission denied
rm: cannot remove ‘/var/run/mysqld/mysqld.pid’: Permission denied
140727 00:42:17 mysqld_safe Fatal error: Can't remove the pid file:
/var/run/mysqld/mysqld.pid
Please remove it manually and start /usr/bin/mysqld_safe again;
mysqld daemon not started
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
Similarly, if I try to start the server as root:
mysqld_safe -p -u root
140727 00:54:08 mysqld_safe Logging to '/var/log/mysql/error.log'.
140727 00:54:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
/usr/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
140727 00:54:08 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
/usr/bin/mysqld_safe: 129: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
Apparently there are many places where I should be changing permissions, which does not look like the way to go. Three questions:
Is there some evident point where I went wrong, or should I just uninstall and apt-get everything?
Should I have owner mysql and group mysql for all files that the server needs to update?
Is there a comprehensive list of locations where these files are?
You cannot create /var/log/mysql/error.log. First create the directory if it doesn't exist
sudo mkdir -p /var/log/mysql
Next, change ownership
sudo chown -R mysql /var/log/mysql
and then try again to start the server as root:
sudo mysqld_safe --user=mysql &
If the server does not start paste here the error messages

MySQL pid ended (cannot start mysql)

I have a clean install of MySQL (mysql-5.5.24-osx10.6-x86_64). I am on Lion (OS 10.7.4) with a Mac Pro Quad Core. I installed MySQL the GUI installer and also installed the pref pane and the startup item.
However when I run:
sudo ./bin/mysqld_safe
I get this message:
120515 17:58:19 mysqld_safe Logging to '/usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.err'.
120515 17:58:19 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.5.24-osx10.6-x86_64/data
120515 17:58:20 mysqld_safe mysqld from pid file /usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.pid ended
I also cannot start MySQL from the preference pane.
Here is what I have tried so far based on the hours of Googling and research today:
Permissions issues?
This:
cd /usr/local
sudo chown mysql mysql
sudo chown mysql mysql-5.5.24-osx10.6-x86_64
sudo chown _mysql mysql
sudo chown _mysql mysql-5.5.24-osx10.6-x86_64
and
sudo chown -R /usr/local/mysql-5.5.24-osx10.6-x86_64/
sudo chown -R /usr/local/mysql
This:
sudo chown -R root:wheel /Library/StartupItems/MySQLCOM
Link issues?
This:
in /usr/local/mysql/support-files/mysql.server -- I did:
basedir="/usr/local/mysql"
datadir="/usr/local/mysql/data"
In the file /etc/rc.common add the follow line at end:
/usr/local/mysql/bin/mysqld_safe --user=mysql &
This:
sudo ln -s /usr/local/mysql-5.5.24-osx10.6-x86_64 /usr/local/mysql
I also tried the removal process here and reinstalled but this did not seem to make a difference. I also launched Activity Monitor in OS X to see if any other mySQL processes were running by chance but they were not.
Nothing above worked so I am sort of at wits end. Here is the log from the .err file located at:
/usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.err
120515 18:07:43 mysqld_safe mysqld from pid file /usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.pid ended
120515 18:13:01 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.5.24-osx10.6-x86_64/data
120515 18:13:01 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.5.24-osx10.6-x86_64/data/ is case insensitive
120515 18:13:01 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql-5.5.24-osx10.6-x86_64/bin/mysqld: Table 'mysql.plugin' doesn't exist
120515 18:13:01 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120515 18:13:01 InnoDB: The InnoDB memory heap is disabled
120515 18:13:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120515 18:13:01 InnoDB: Compressed tables use zlib 1.2.3
120515 18:13:01 InnoDB: Initializing buffer pool, size = 128.0M
120515 18:13:01 InnoDB: Completed initialization of buffer pool
120515 18:13:01 InnoDB: highest supported file format is Barracuda.
120515 18:13:01 InnoDB: Waiting for the background threads to start
120515 18:13:02 InnoDB: 1.1.8 started; log sequence number 1595675
120515 18:13:02 [ERROR] /usr/local/mysql-5.5.24-osx10.6-x86_64/bin/mysqld: unknown option '--skip-locking'
120515 18:13:02 [ERROR] Aborting
120515 18:13:02 InnoDB: Starting shutdown...
120515 18:13:03 InnoDB: Shutdown completed; log sequence number 1595675
120515 18:13:03 [Note] /usr/local/mysql-5.5.24-osx10.6-x86_64/bin/mysqld: Shutdown complete
120515 18:13:03 mysqld_safe mysqld from pid file /usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.pid ended
Update: I upgraded the same machine from Snow Leopard to Mountain Lion 10.8.1 and MySQL works perfectly fine now with the upgrade, I had to do nothing extra.
I have the same problem when installing mysql newest version mysql-5.6.10-osx10.7-x86.dmg for my MAC OS 10.7.5. Following is my solutions.
First , delete the mysql installed
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
Then, get mysql-5.1.68-osx10.6-x86.dmg , install this old version, and done!
As #AndPy says, the same with me, if you ls -l the /usr/local/var/mysql you can see that the file COMPUTER-NAME.local.err is owned by _mysql or some such.... in this case just erase the file and mysql.server start will create new one owned by your user and will start properly this time :)
If the file is already owned by your user, this wont help, you got to google more :(
I found this error on redmine bitnami stack because owner of files in directory data incorrect.
Check owner of directory /mysql/data/ must be 'mysql' user
Hope this help.
I had the same problem after updating to OS X Mavericks.
Starting MySQL . ERROR! The server quit without updating PID file
Like Redrick and AndPy mentioned I also had to rename (actually I deleted the file) the error file located in $ cd /usr/local/var/mysql. My error file was called localhost.err. After removing the file with $ rm localhost.err I could finally start MySQL again with $ mysql.server start.
I had the same problem.
In /usr/local/var/mysql I found a file in the form COMPUTER-NAME.local.err. Simply changing that file name solved the problem. I could now start the mysql server with
mysql.server start
My answer is very similar to others, but slightly different and this applies mostly to a bitnami mamp stack. The fix for me was:
sudo chown -R mysql mysql/
The mysql/ directory is the one located in Applications/<mampstack-version>/
The above sets the mysql to be the owner of the mysql directory recursively into the other directories.
If you want to absolutely get this thing working do the following:
You need to uninstall mysql first so do that, before you do this though, make sure you have a backup of all your DBs.
brew remove mysql
Then you need to make sure certain files are uninstalled, make a batch script of the following commands and run it:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
Go to /etc/hostconfig using your favorite editing program and remove the line MYSQLCOM=-YES-
Then run brew cleanup then install mysql using brew install mysql
After you've done this you'll probably get the same error again. Head over to the folder cd /usr/local/var/mysql/. There should be a file in there called localhost.local.err
run cat ./localhost.local.err and look in the file. You should see something similar to:
2018-03-24 15:41:49 140735679804288 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 48: Address already in use
2018-03-24 15:41:49 140735679804288 [ERROR] Do you already have another mysqld server running on port: 3306 ?
If you do, run the command sudo lsof -i :3306 and you'll probably get something back like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 74 _mysql 20u IPv6 0xXXXXXXXXXXXXX 0t0 TCP *:mysql (LISTEN)
This means mysql is already running and listening on port 3306 and you need to kill it. Use top to kill the program or just use Activity Monitor to kill it. Either way once that's done go back to cd /usr/local/var/mysql/ and delete the folder localhost.local.err.
Once that's done run mysql.server start and you should get the following:
180324 15:46:18 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
SUCCESS!
And congrats. I've been trying to fix this for a week and it's such an easy fix and I just figured it out. I hate myself.
120515 18:13:01 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
Regarding this error, I assume that you have specified a datadir in my.cnf. If you are using a non-default data directory for MySQL, you need to move folders mysql and performance_schema (whichever exists) to the data directory specified in my.cnf. You can find these folders in mysql directory.
In MySQL 5.5+ the --skip-locking option is removed. Use --skip-external-locking instead. Refer to MySQL documentation --> http://dev.mysql.com/doc/refman/5.5/en/mysql-nutshell.html
Quote: "The --enable-locking and --skip-locking server options (use --external-locking and --skip-external-locking)."
Give this a whirl..
Navigate to the problem's parent directory cd YOURPATH/usr/local/mysql
rm -rf *.local.err (deletes file)
touch YOURUSERNAME.local.pid (generates new *.local.pid file the error thrown was complaining about)
cd back into your project and restart mysql using mysql.server start
Only removing mysql-bin.index file in /usr/local/var/mysql/ helped me.
I've tried many hours, But this works for me,
Simply change the ownership of the MySQL directory file to the user called 'mysql'.
chown -R mysql <path>/mysql-5.7.39-linux-glibc2.12-x86_64

How to change mysql.sock?

I have installed mysql through binary installation and followed below steps
http://dev.mysql.com/doc/refman/5.0/en/binary-installation.html
Right now sock files are craeted on /tmp/mysql.sock when mysql service is started.
I want to know which configuration files need to be edited to change the path of mysql.sock
I tried the following steps to change mysql.sock path from /tmp/mysql.sock to /var/lib/mysql/mysql.sock
1.I tried to enter socketpath in /etc/my.cnf
socket =/var/lib/mysql/mysql.sock
2./etc/init.d/mysql
basedir=/var/lib/mysql
datadir=/var/lib/mysql/data
socket=/var/lib/mysql/mysql.sock
Can anybody help me to fix this issue.
Setting these variables in my.cnf should work just fine (Tested locally, Ubuntu 10.10).
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Just make sure you're restarting MySQL Service?
Below is what I did, this is on Fedora (Since you're using RHEL this should more mimic your setup):
[root#rudi /]# ls /var/lib/mysql/
ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock
[root#rudi /]# ls /var/run/mysqld/
mysqld.pid
[root#rudi /]# nano /etc/my.cnf
[root#rudi /]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root#rudi /]# ls /var/lib/mysql/
ibdata1 ib_logfile0 ib_logfile1 mysql
[root#rudi /]# ls /var/run/mysqld/
mysqld.pid mysql.sock
The only thing that I changed was socket= this time, and restarting still worked fine.
Are you sure that you're not editing socket within the [client] section of my.cnf? It must be under the [mysqld] section.