How to solve InnoDB: Unable to lock ./ibdata1 mysql error? - mysql

2016-03-14 02:30:29 58150 [ERROR] InnoDB: Unable to lock ./ibdata1,
error: 35 2016-03-14 02:30:29 58150 [Note] InnoDB: Check that you do
not already have another mysqld process using the same InnoDB data or
log files.

First, list MySQL processes using the ps command:
ps aux | grep mysql
And then kill the process
sudo kill 56311

Believe it or not, the solution is elsewhere. The problem stems from AppArmor misconfiguration apparently.
So just do:
$ apt install apparmor-profiles
and then restart MySQL (notice how fast it'll restart).
I noticed a file missing related to AppArmor when doing:
$ systemctl status mysql.service
Voila.

It should say "There is another solution: the problem might be AppArmor". If you do not see an entry in /var/log/apport.log, then probably AppArmor is not the problem.
An intriguing solution, however.

Related

mariadb will not start following a power cut

Everything was fine until a power cut and now mariadb will not start. the below is logged in /var/log/mariadb/mariadb.log.
200927 18:01:15 mysqld_safe Starting mysqld daemon with databases
from /var/lib/mysql /usr/libexec/mysqld: symbol lookup error:
/usr/libexec/mysqld: undefined symbol:
_ZN14JOIN_CACHE_BNL28get_lext_candidate_for_ma|chEv
200927 18:01:15 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
Regards
Matt
I've managed to solve this, but not fully sure how.
I did have other issues reported originally as warning:
Found row where the auto_increment column has the value 0
client is using or hasn't closed the table properly
I ran
myisamchk -s /var/lib/mysql//.MYI
myisamchk -r --update-state /var/lib/mysql//.MYI
I did try mysqlcheck first but it would not work as the service was not up.
It appears all I needed to do afterward was another system reboot and that cleared the last error.
Regards
Matt

MySQL on OSX Sierra can't start: The server quit without updating PID file

Several problems with mysql since last Sierra Update.
Reinstalled several times with brew or mysql dmg and followd many many "solutions" on SO.
Finally it worked but after a Mac Crash, I face the same problem.
MySql won't start from preference panel
Mysql won't start from terminal: Can't connect through /tmp/mysql.sock...of course, mysqld is not running
trying to start mysqld:
sudo /usr/local/mysql/support-files/mysql.server start
ERROR! The server quit without updating PID file (/usr/local/mysql/data/My-iMac.local.pid)
sudo /usr/local/mysql/bin/mysqld several errors and shutdown
a bit stuck
Just tried this
sudo /usr/local/mysql/bin/mysqld_safe
mysqld_safe Logging to '/usr/local/mysql/data/My-iMac.local.err'.
Starting mysqld daemon with databases from /usr/local/mysql/data
mysqld_safe mysqld from pid file /usr/local/mysql/data/My-iMac.local.pid ended
And now looking at error log, the explanation is clear:
tail /usr/local/mysql/data/My-iMac.local.err
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
So I added in my.cnf
[mysqld]
innodb_force_recovery = 1
and now it starts!
It was probably due to previous Mac Crash
In my case the owner of the data folder was changed after an OS update.
After fixing this with …
sudo chown -R mysql /usr/local/mysql/data
… everything worked like a charm again.
Oh, I feel your pain. I've had this happen many times. Stopping the processes didn't always work. To solve this I simply went into System Preferences and MySQL... stop the process from there and try to restart.

MySQL privilege tables

I downgraded from 5.6 to 5.5 and now I can't start mysql. Log files show the following:
50421 12:11:10 [ERROR] /usr/sbin/mysqld: Incorrect information in file: './mysql/proxies_priv.frm'
150421 12:11:10 [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect information in file: './mysql/proxies_priv.frm'
I've done the following to try and resolve but no joy:
chgrp -R mysql /var/lib/mysql
chown -R mysql /var/lib/mysql
and I've also tried the following:
mysql_install_db --user=mysql --ldata=/var/lib/mysql
Which gives this error message:
Installing MySQL system tables...
150421 12:18:01 [ERROR] /usr/sbin/mysqld: Incorrect information in file: './mysql/tables_priv.frm'
ERROR: 1033 Incorrect information in file: './mysql/tables_priv.frm'
I have Googled the problem for about an hour now and am still struggling. Any help appreciated.
I dealt with this by first purging mysql using:
sudo apt-get purge mysql-server-<version>
Then I deleted everything in/var/lib/mysql and ran
sudo apt-get install mysql-server-<version>
I've recently had to deal with this problem as well. Before an upgrade, it's always a good idea to backup the mysql system tables. That way, if you need to rollback, you can get yourself back to a good state.
That being said, here we are. Try this:
1. rm -rf /var/lib/mysql/mysql/* (As suggested by user3392517)
2. mysql_install_db --user=mysql --ldata=/var/lib/mysql
3. start mysqld
4. mysql_upgrade --force
As with most errors that takes day or more to resolve i resorted to extreme measures:
rm -rf /var/lib/mysql/mysql/*
Fixed the problem.
Note: Data loss did occur, but this a development server so I did not care.
Delete the file as root or sudo
rm /var/lib/mysql/mysql/proxies_priv.frm
Then restart MySQL.
I didn't lose any data this way.

MySQL on ubuntu 12.04 won't run after MySQL Workbench installed

Recently I installed MySQL Workbench 6.2 and used it to create ER diagrams of the MySQL 5.5.41 databases I'm working with on Ubuntu 12.04. Everything worked fine until I restarted Ubuntu and suddenly mysql was no longer running. Running mysqld from the command line results in this:
150216 12:50:37 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'
150216 12:50:37 [Warning] Can't create test file /var/lib/mysql/euler.lower-test
150216 12:50:37 [Warning] Can't create test file /var/lib/mysql/euler.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
150216 12:50:37 [ERROR] Aborting
150216 12:50:37 [Note]
The file /usr/share/mysql/english/errmsg.sys exists, owned by root, with permissions 644. The directory /var/lib/mysql exists, owned by mysql, with permissions 700.
I'm guessing that the installation of Workbench changed something (maybe config files) so that mysql is no longer working, but after a fair amount of Internet research, I have not discovered how to solve this problem. Any help will be greatly appreciated.
Seems like file permission problem. Try running mysqld again using sudo
If this doesn't help, maybe you shouldn't be starting it directly via mysqld. Check if the installer package added a service
sudo service --status-all | grep mysql
And if one exist, use it to start mysql, typically:
sudo service mysqld start
Also don't forget to check if mysqld is already running. If so you can't start duplicate process. I know this sound silly but has happened to me before
ps -ef | grep mysqld

Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root

I am not sure how to fix this:
dyn-72-33-214-45:python mona$ sudo /usr/local/mysql/bin/mysqld stop
2014-09-06 09:49:04 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-06 09:49:04 22992 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.6.15-osx10.7-x86_64/data/ is case insensitive
2014-09-06 09:49:04 22992 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2014-09-06 09:49:04 22992 [ERROR] Aborting
2014-09-06 09:49:04 22992 [Note] Binlog end
2014-09-06 09:49:04 22992 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
I'm using OS X (Yosemite) and this error happened to me when I upgraded from Mavericks to Yosemite. It was solved by using this command
sudo /usr/local/mysql/support-files/mysql.server start
you might try this if you logged in with root:
mysqld --user=root
The MySQL daemon should not be executed as the system user root which (normally) do not has any restrictions.
According to your cli, I suppose you wanted to execute the initscript instead:
sudo /etc/init.d/mysql stop
Another way would be to use the mysqladmin tool (note, root is the MySQL root user here, not the system root user):
/usr/local/mysql/bin/mysqladmin --port=8889 -u root shutdown
Try this for Amazon Linux AMI or for centOS
sudo service mysqld restart
How i resolved this was following the 4th point in this url: https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html
Edit my.cnf
Add user = root under under [mysqld] group of the file
If this doesn't work then make sure you have changed the password from default.
I also had the same problem and able to resolve after using below command
/root/mysql-sandboxes/3320/bin/mysqld --defaults-file=/root/mysql-sandboxes/3320/my.cnf --user=root &
osx could be using launchctl to launch mysql. Try this:
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
Donal had the right solution for me. However, the updated plist name for 2017 is
com.oracle.oss.mysql.mysqld.plist.
in my case (RHEL7 and MariaDB) this works.
sudo systemctl restart mariadb
On top of #mise's answer,
After I installed MacOS Mojave, I also had to change files ownership on all my MAMP directory and contents).
From the Finder, I went in Application/MAMP, showed files info (cmd + i) and in permissions section added myself with read & write perms, then from the little gear applied to all the children.
The correct answer that worked for me on CentOS is
/etc/init.d/mysql restart
which is an init script and not /etc/init.d/mysqld restart, which is binary
The is in fact comment of #MrTux on the question which worked for me. It took quite a bit of my time hence posting it as answer.
to run mysqld as root user from command line you need to add the switch/options
--user=root
mariadb run as system root user
I had this issue while running MySQL on Minikube (Ubuntu box) and I solved it with:
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
Very weird, but I got this error when I made a typo in the my.cnf file.
So it had nothing to do with the user directive not defined or not running as root-user.
My mistake was:
bind=192.168.1.2
instead of
bind-address=192.168.1.2