问题
My server is running on Ubuntu 16.04 I hade some issue with my MySQL configuration, so I've decided to clean up and reinstall the MySQL server.
After this command:
sudo apt-get install mysql-server
This is what i got at the end of the process:
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up libhtml-tagset-perl (3.20-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up libhtml-parser-perl (3.72-1) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libhttp-message-perl (6.11-1) ...
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Processing triggers for systemd (229-4ubuntu13) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
I try to start the MySQL and running systemctl status mysql.service
gave this:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Tue 2016-12-20 17:33:32 BDT; 14s ago
Process: 22634 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 22631 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 22634 (code=exited, status=1/FAILURE); : 22635 (mysql-systemd-s)
Tasks: 2
Memory: 1.5M
CPU: 337ms
CGroup: /system.slice/mysql.service
└─control
├─22635 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─22669 sleep 1
When I try to connect the database using mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
回答1:
I meet same problem today, and finally I found out this is because in my.cnf there is something like that:
log_slow_queries = /var/log/mysql/mysql-slow.log
But in Mysql 5.7, log_slow_queries is deprecated, change to
slow_query_log_file = /var/log/mysql/mysql-slow.log
solved my problem.
回答2:
Make sure there is no other mysql process running. I had an dead mysql process running, which caused in a conflict / upgrade error.
ps -aux | grep 3306
If there are any "dead" mysql processes, kill them like this `sudo kill -15 {pid here}.
Then run the upgrade again.
Cheers Unkn0wn0x
回答3:
You may want to try installing from source so you can try to pinpoint what is exactly causing the problem.
First remove all partially installed mysql packages using:
$ sudo apt-get remove --purge mysql\*
Then follow this guide:
https://dev.mysql.com/doc/refman/5.7/en/source-installation.html
Alternatively, you could install MariaDB which is a drop-in replacement for mysql:
$ sudo apt-get install mariadb-server
I have started using MariaDB on Ubuntu instead of MySQL and it works well for me.
来源:https://stackoverflow.com/questions/41241494/issues-on-reinstalling-mysql-5-7-server-on-ubuntu-16-04