I'm a newbie on MySQL ground so bear with me.
I've just finished upgrading 11.10 to 12.04.
Everything seemed to work without any hiccups and all my software and settings are working fine. Apart from MySQL.
When I try:
sudo start mysql
I receive an error:
start: Job failed to start
Where can I possibly diagnose what the problem is? And (hopefully) - how to sort it out?
(I disabled automatic start following advice here if that is of some importance)
Update 1:
Both outputs of:
cat /var/log/mysql.err
cat /var/log/mysql.log
are empty.
Output of dmesg | grep mysql
:
[ 1401.785141] type=1400 audit(1335619832.181:25): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=16165 comm="apparmor_parser"
[ 1401.791089] init: Failed to spawn mysql main process: unable to execute: No such file or directory
Update 2:
As indicated by AWinter below - it seemed that MySQL disappeared automagically after upgrade and had to be reinstalled.
Check that mysql-server-5.1 package was uninstalled, seems it might persist after upgrade. I had the same error and had to purge MySQL server 5.1 and 5.5 then re-install.
First make a backup of your /var/lib/mysql/ directory just to be safe.
Next purge MySQL (this will remove php5-mysql and phpmyadmin as well as a number of other libraries so be prepared to re-install some items after this.
Remove the folder /etc/mysql/ and it's contents
Next check that your old database files are still in /var/lib/mysql/ if they are not then copy them back in to the folder then chown root:root
(only run these if the files are no longer there)
Next install mysql server
Finally re-install any missing packages like phpmyadmin and php5-mysql.
I had this same issue and for me it was the InnoDB logfiles were a different size than mysql was expecting, and failed silently during upgrade.
I had a custom configuration file that was wiped out on the upgrade to 12.04 that set the log file sizes to something other than what the default configuration.
You have to remove the files: /var/lib/mysql/ib_logfile*
After the files are gone, mysql can now start and create fresh log files of the default size.
Most errors will show up by starting the server in verbose non-daemon mode and watching the output:
I had the same problem, but none of the answers above helped me. So as a final hope I tried to free some disk space. I simply remove unnecessary log files from /var/log which freed some 2.5G space. Then MySQL started normally.
This sometimes happens and although there are a couple of different problems that could make mysql not start I will write here some of the most common ones that I know of:
NOTE - Because explaining most common problems I am assuming that you have already tried removing and installing, or simply reinstalling the mysql service as so:
To Install -
sudo apt-get install mysql-server mysql-client
To Remove -
sudo apt-get remove mysql-server mysql-client
To Purge (Remove files + Config) -
sudo apt-get purge mysql-server mysql-client
To Reinstall -
sudo apt-get install --reinstall mysql-server mysql-client
my.cnf
file is not in the default directory. It should be (By default) be located in either/etc/my.cnf
or/etc/mysql/my.cnf
.Not enough space in the hard drive where the mysql data files are located. If the Databases get too big and take 100% of the hard drive, the service will fail.
After upgrade check that the
my.cnf
file is in the correct place. Depending on how you upgraded or from what version you upgraded from, it could be in/etc/my.cnf
or/etc/mysql/my.cnf
as mentioned before. Also remember that the file can also be namedmysql.conf
and not justmy.cnf
. This happens in cases where you have downloaded the binary from mysql.com.Doing a
dmesg
to see what the mysql service is is throwing as an error message helps since it gives the loading error. It might also say why this is happening. If you typedmesg
alone in the terminal it will show you the world. What we want is the info about mysql so do something like this:dmesg | grep mysql
this will throw you any lines that contain mysql in them.Check that the
my.cnf
ormysql.conf
file is correct. In 12.04 MySQL is version 5.5, in 11.10 it is version 5.1. It might have some changes in the conf file (Haven't actually checked that) and it might sound silly but it sure can give you some trouble.Errors related to socket problems normally are the fault of the
my.cnf
ormysql.conf
file pointing to the wrong place, they error will normally show as:The other source of this problem is related to the
mysql
file in/etc/init.d
that it is pointing at the wrong folder because it might be using an older script than the one needed for the actual mysql on the system (It might not have updated correctly, did not overwrite the config file, etc..). So just edit any of this two files and see if they are pointing somewhere else and then simply do asudo service mysql restart
to check if it works.To have a better look at the error specific outputs of mysql do the following:
cat /var/log/mysql.err
- Will show you the mysql errors. I would make it like thiscat /var/log/mysql.err | less
if you happen to see too much information fly by sinceless
will help you scroll your way through the output ofcat
.Same goes for
cat /var/log/mysql.log
If you see the error there maybe putting it in the question or as a comment will help answer this faster.If you are suffering from connection problems and the service it is actually running, try to see if the Firewall of the server is allowing connections through the 3306 port (Incoming connections). Afterwards check if the router (If it applies) has not blocked port 3306. Basically do a network test to see where the problem related to the port assigned to mysql is originated from.
If all is good, to test if the mysql service is running type
service mysql status
As a last resort. If you happen to be running mysql but you can not login try the following:
Stop the MySQL Server:
sudo /etc/init.d/mysql stop
orsudo service mysql stop
Start the
mysqld
service manually with manual configurationsudo mysqld --skip-grant-tables &
(Remember to add the & else you will have to open another terminal. The & sends the process to the background and you can kill on using the same terminal).
Login to the mysql database as ROOT
mysql -u root mysql
Type the following replacing the MyPASSWORD with your new password
UPDATE user SET Password=PASSWORD('MyPASSWORD') WHERE User='root';
FLUSH PRIVILEGES;
EXIT;
This should be enought to login to your Mysql service as root again. Hope it helps.
I had the same problem after upgrading to Ubuntu Server 12.04 LTS, running
was enough to fix it, although it complained about an old database of spotweb. I fixed that by removing spotweb:
and reconfiguring mysql:
I will add this incase someone faces similar issues. I tried all the uninstalling and re-installing to no avail. The key to finding the solution was that upstart places it's error logs in this folder
/var/log/upstart/
for mysql
/var/log/upstart/mysql.log
when I opened it had this message
When I looked in the /etc/apparmor.d/tunables/ folder I was missing the home file in that so I created one
gedit /etc/apparmor.d/tunables/home and copied the contents from another computer which had these non commented lines
someone face a similar issue here
https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/982303
then after that I was able to restart the service
In my case it was way easier than some answers here. I found the related bug on launchpad and the fix was as mentioned there in comment 9:
After upgrading I found that mysql-server/mysql-server-5.5 was not installed and neither 5.1. I renamed my.cnf to my.cnf_old and I tried to install mysql-serven. During installation there was an error message that the root password could not be set. After this I checked my configs, apparmor and so on. All seemed to be ok. My next attempt was to reconfigure mysql-server but it complained that the package was not installed completely. So I decided to uninstall and during this apt-get fixed the package and now it is working. I don't know why because I changed nothing.