Mysql not running after upgrading mysql version - mysql

Following this link I upgraded my MySQL version from 5.5 to 5.7 on my ubuntu 14.04 droplet. But after upgrading MySQL is unable to start showing this error.
mysqld: Can't read dir of '/etc/mysql/mysql.conf.d/' (Errcode: 13 - Permission denied)
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
How to resolve this problem?

In my case AppArmor was preventing MySQL from accessing this directory. I disabled 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
I found this solution here.
Another approach would be to adjust configuration inside /etc/apparmor.d/usr.sbin.mysqld.

You try to use chmod to set permissions for the folder
chmod 755 /etc/mysql/mysql.conf.d
mysql.conf.d is a new file can be added

Sometimes the reason mysql don't start or work is because your system memory is probably full, so you may need to run "apt autoremove" and sometimes "apt autoclean", to be sure on what is wrong exactly run "service mysql status"

These are the steps 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
Backup and remove /etc/mysql/debian.cnf files (not sure if needed, but just in case)
sudo mv /etc/mysql/debian.cnf /etc/mysql/debian.cnf.bak
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.

Some times mysql will not start due to your system memory is probably full or some dependency issues. so you may need to clean your memory before start mysql.
you can try this to resolve your issue
apt-get autoremove
apt-get remove --purge mysql*
apt-get autoclean
deluser mysql
rm -rf /var/log/mysql
rm -rf /var/lib/mysql
rm -rf /etc/mysql
Anyway these are the correct steps to upgrade mysql
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
Backup and remove /etc/mysql/debian.cnf files (not sure if needed, but just in case)
sudo mv /etc/mysql/debian.cnf /etc/mysql/debian.cnf.bak
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

Related

MySQL installed via HomeBrew Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I've been searching for hours about this issue i'm having.
I have installed mysql#5.7 in my mac osx Monterey 12.0.1 with M1 chip using Homebrew.
I've been following this tutorial that helped me install mysql version 5.7. I'm specifying this version because i'm recreating a production environment on local.
At the step where I need to secure my mysql installation I type user root password and get this error Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
I have read many ways to fixing this but I can't make it work with any of those because most of them don't relate to homebrew or don't work well for me.
I have the service running using the brew services start mysql#5.7 command and this doesn't seem fixing the issue.
Is there any possibility I can't make it run because I have an M1 chip?
I researched again and remembered that I had previously installed a MySQL 8.X version. I uninstalled it only using the brew uninstall command. This wasn't enough and I made sure I deleted all the mysql related files and folders from my computer.
After that I retried installing MySQL 5.7 as a completely fresh install. Then at this same step where I had trouble before I didn't have any issue, I followed the installation and now is up and running.
These are all the files I found were related to other MySQL installations, you may or may not have them in your system but I suggest to try delete them all, here I paste the commands needed:
ps -ax | grep mysql
stop and kill any MySQL processes
brew remove mysql
brew cleanup
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
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
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*
/opt/homebrew/var/mysql
/opt/homebrew/etc/my.cnf
Do you have the mysql.sock in your /tmp?
You can make a symlink, depending on your installation
ln -s /var/mysql/mysql.sock /tmp/mysql.sock

Cannot open MySQL for the first time

I have installed MySQL from Ubuntu software center, MySQL client and MySQL workbench as well.
the problem is I cannot do anything but to call sudo mysql start and sudo mysql stop
when i try to run the following command sudo /usr/bin/mysql_secure_installation i am prompted to enter the root password, i didn't set the root password so i just clicked 'Enter'
I got the following
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I went to /var/run/mysqld and i have found that it is completely empty.
Update
I don't know if that would help, but I have tried to find the PID file by using find / -type f -name "*.pid" command . I haven't found any files related to mysql with the extension .pid
I was removing the installation without sufficient commands, as it seems, finally i have removed it using the following :
#sudo service mysql stop
#sudo killall -9 mysql
#sudo killall -9 mysqld
#sudo apt-get remove --purge mysql-server mysql-client mysql-common
#sudo apt-get autoremove
#sudo apt-get autoclean
#sudo deluser mysql
#sudo rm -rf /var/lib/mysql
#sudo apt-get purge mysql-server-core-5.5
#sudo apt-get purge mysql-client-core-5.5
This time i have removed the user as well. I didn't know that would matter. anyway after reinstalling it again it worked just fine

Trouble reinstalling mysql on OSX Mavericks

I'm trying to reinstall mysql on my computer (os x mavericks) and I've done the following with the following errors:
bash <(curl -Ls http://git.io/eUx7rg)
Error:
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/mysql/data/christians-mbp.saumag.edu.pid).
/usr/local/mysql/support-files/mysql.server: line 362: pidof: command not found
/dev/fd/63: line 119: SORRY, MySQL IS NOT RUNNING ... THERE MUST BE A PROBLEM: command not found
So I decided to see uninstall it if it was already there:
brew uninstall mysql
bash <(curl -Ls http://git.io/eUx7rg)
This says that mysql is currently still installed, so I did the following:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
bash<(curl -Ls http://git.io/eUx7rg)
This gave me the same error messages as before, So I decided to redo all the rm commands above, including the edit and run the following commands:
ps -ax | grep mysql
brew cleanup
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
brew doctor
brew update
brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=`yyttr3` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
After the last command I got the following error message:
dyld: Library not loaded: ##HOMEBREW_PREFIX##/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/opt/mysql/bin/my_print_defaults
Reason: image not found
FATAL ERROR: Neither host 'christians-mbp.saumag.edu' nor 'localhost' could be looked up with
/usr/local/opt/mysql/bin/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option
I don't really know what the problem is, i'm not sure if i'm even installing it right. From what I have read this should be a good way to install mysql. If you have any ideas on what I would greatly appreciate it.
I'm sure you've solved this by now, but I just had the same problem. For anyone else who stumbles across this:
For me, it was an issue with OpenSSL.
resolveip `hostname`
If it says OpenSSL isn't loaded,
brew uninstall openssl
brew install openssl
then try again. Hope this helps.
I had the same problem. Only solution that I found is to install mysql from source code. The reason for this error to occur and how to solve it is explained in full detail in the following link: http://jaitechwriteups.blogspot.com.au/2010/08/mysql-installation-error-neither-host.html
All I had to do was agree XCODE terms by opening XCODE. That fixed everything.

Couldn't start MySQL! while starting XAMPP

I am new in Ubuntu, I installed XAMPP in my Ubuntu 10.04. When I start XAMPP it says MySQL couldn't start.
Here is my terminal ouput:
$ sudo /opt/lampp/lampp start
Starting XAMPP for Linux 1.8.0...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Couldn't start MySQL!
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
And then as I go to http://localhost, I got stuck on the XAMPP splash-screen, nothing happens if I choose language.
This Worked For me as a Charm. [I used Ubuntu 12.04 and Xampp]
sudo chmod 755 /opt/lampp/etc/my.cnf
sudo chmod -R 777 /opt/lampp/var/mysql
sudo chown -hR root:root /opt/lampp
& Now Start Your Xampp
It might just be that the /opt/lampp doesn't have the right permissions. Before reinstalling everything, try running the commands below, it worked for me:
sudo /opt/lampp/lampp stop
sudo chmod 755 /opt/lampp/etc/my.cnf
sudo chmod -R 777 /opt/lampp/var/mysql
sudo chown -hR root:root /opt/lampp
sudo /opt/lampp/lampp start
Just remove the version where the MySQL is not started with the command rm -rf /opt/lampp
and the command:
tar xvfz xampp-linux-1.8.1.tar.gz -C /opt
Replace xampp-linux-1.8.1.tar.gz with your file name. After restarting your lampp, it will work fine.
You may not have completely removed your old lampp instance. Please remove it and install lampp once again.
It might be the right permissions problem. Some solutions guide you to set it to 777 which is not recommended. Try to set it to original permissions as installed. (especially after you restore from a tar without preserving the permissions)
sudo /opt/lampp/lampp stop
sudo chown nobody.root /opt/lampp/var/mysql/cdcol /opt/lampp/var/mysql/mysql /opt/lampp/var/mysql/phpmyadmin -R
sudo chown nobody.nogroup /opt/lampp/var/mysql/yourdbname -R
sudo /opt/lampp/lampp start
Even I had the same issue. Always check for the error log before proceeding to find the root cause. Sometimes it could be file system space issue. In my case it was "/" file system was full. After clearing some space I was able to start the services without issues.
Thanks,
Vishnu
XAMPP started successfully on my side, but still got stuck at spalsh screen.
It was solved by giving permission to lang.tmp file
sudo chmod 777 /opt/lampp/htdocs/xampp/lang.tmp
Your previous MySQL installation might be blocking your MySQL from the xampp bundle. I also had the same problem. Just uninstall the previous MySQL. Open the terminal(Ctrl ALt T) and paste the following code:
First stop XAMPP:
sudo /opt/lampp/lampp stop
Uninstall MySQL:
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
Start XAMPP:
sudo /opt/lampp/lampp start
I found the answer. First completly uninstall the lampp and then reinstall it. Before uninstalling, stop the lampp using the command:
/opt/lampp/lampp stop
and then uninstall/remove it using the command
rm -rf /opt/lampp
then reinstall it.

Install MySQL 5.5 in Ubuntu 11.10

I have been downloaded the DEB package of mysql 5.5.23.
Install MySQL by the command as follows:
sudo dpkg -i mysql-5.5.23-debian6.0-x86_64.deb
The result said that installed successfully.
But when I type the command:
sudo service mysql start
Or
mysql
It shows me that "mysql: unrecognized service" or "mysql: command not found".
Besides, I can't find MySQL files in "/usr/include" or "/usr/bin"
Please help me. Thx.
Because MySQL 5.5.x is not packaged, in repositories only exist 5.1.x
This worked for me:
http://www.rebojo.com/debian-installing-mysql/
Why not a simple command :
sudo apt-get install mysql-server
MySQL Download URL
https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Open the terminal and follow along:
Uninstall any existing version of MySQL
sudo rm /var/lib/mysql/ -R
Delete the MySQL profile
sudo rm /etc/mysql/ -R
Automatically uninstall mysql
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
Download version 5.5.51 from MySQL site
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Add mysql user group
sudo groupadd mysql
Add mysql (not the current user) to mysql user group
sudo useradd -g mysql mysql
Extract it
sudo tar -xvf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Move it to /usr/local
sudo mv mysql-5.5.56-linux-glibc2.5-x86_64 /usr/local/
Create mysql folder in /usr/local by moving the untarred folder
cd /usr/local
sudo mv mysql-5.5.49-linux2.6-x86_64 mysql
set MySql directory owner and user group
cd mysql
sudo chown -R mysql:mysql *
Install the required lib package (works with 5.6 as well)
sudo apt-get install libaio1
Execute mysql installation script
sudo scripts/mysql_install_db --user=mysql
Set mysql directory owner from outside the mysql directory
sudo chown -R root .
Set data directory owner from inside mysql directory
sudo chown -R mysql data
Copy the mysql configuration file
sudo cp support-files/my-medium.cnf /etc/my.cnf
Start mysql
sudo bin/mysqld_safe --user=mysql &
sudo cp support-files/mysql.server /etc/init.d/mysql.server
Set root user password
sudo bin/mysqladmin -u root password '[your new password]'
Add mysql path to the system
sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
Reboot!
Start mysql server
sudo /etc/init.d/mysql.server start
Stop mysql server
sudo /etc/init.d/mysql.server stop
Check status of mysql
sudo /etc/init.d/mysql.server status
Enable myql on startup
sudo update-rc.d -f mysql.server defaults
*Disable mysql on startup (Optional)
`sudo update-rc.d -f mysql.server remove`
REBOOT!
Now login using below command, start mysql server if it's not running already
mysql -u root -p