ubuntu - ubuntu 16.04 服务器上的 mysql 启动和重启问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43329380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ubuntu - mysql start and restart issue on ubuntu 16.04 server
提问by mohammad fallah.rasoulnejad
i installed mysql 5.7 but then found out I need mysql 5.6 so i deleted all mysql related packages with
我安装了 mysql 5.7 但后来发现我需要 mysql 5.6 所以我删除了所有与 mysql 相关的包
apt-get remove --purge mysql*
so it gotten removed. then i issued:
所以它被删除了。然后我发出:
apt-get install mysql-server-5.6 mysql-client-5.6
so the mentioned packages gotten installed.
but its not starting using systemctl start mysql
or service mysql start
or even restart. the result is this:
所以提到的包被安装了。但它不是开始使用systemctl start mysql
或者service mysql start
甚至重新启动。结果是这样的:
service mysql restart
or
service mysql start
or
systemctl restart mysql
or
systemctl start mysql
returns:
返回:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
but
但
systemctl status mysql
returns
返回
mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-04-10 13:24:00 EDT; 29s ago
Docs: man:systemd-sysv-generator(8)
Process: 15820 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
Main PID: 1323 (code=exited, status=0/SUCCESS)
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Compressed tables use zlib 1.2.8
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using Linux native AIO
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using CPU crc32 instructions
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Initializing buffer pool, size = 128.0M
Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
Apr 10 13:24:00 server mysql[15820]: ...fail!
Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
what is Failed to start LSB: Start and stop the mysql database server daemon.
before installing 5.6 the 5.7 version was working fine but now its like this.
什么是Failed to start LSB: Start and stop the mysql database server daemon.
安装5.6之前的版本5.7中工作正常,但现在它的这个样子。
the /var/log/mysql/errors.log
is empty and these are the /var/log/syslog
last lines
该/var/log/mysql/errors.log
是空的,这是/var/log/syslog
最后的行
Apr 10 13:23:30 server mysqld: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
Apr 10 13:23:30 server mysqld_safe: mysqld from pid file /var/lib/mysql/server.pid ended
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Apr 10 13:24:00 server /etc/init.d/mysql[16277]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Apr 10 13:24:00 server /etc/init.d/mysql[16277]:
Apr 10 13:24:00 server mysql[15820]: ...fail!
Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
output of mysqld_safe
输出 mysqld_safe
170410 13:33:28 mysqld_safe Logging to syslog.
170410 13:33:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170410 13:33:28 mysqld_safe mysqld from pid file /var/lib/mysql/server.pid ended
and this is my /etc/mysql/my.cnf
and there is no /etc/my.cnf
这是我的/etc/mysql/my.cnf
,没有/etc/my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
!includedir /etc/mysql/conf.d/
回答by Nafiu Lawal
This problem arrives when your /etc/mysql/mysql.conf.d/mysqld.cnf file is wrongly set. If you recently made changes to this file please revert to the previous one or copy the default one here
当您的 /etc/mysql/mysql.conf.d/mysqld.cnf 文件设置错误时,就会出现此问题。如果您最近对此文件进行了更改,请还原到上一个文件或在此处复制默认文件
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
#
# * Fine Tuning
#
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
#max_connections = 100
#table_open_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#slow_query_log = 1
#slow_query_log_file = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
#expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
回答by Arpan Saha Mondal
1)First remove already installed mysql-server using-- sudo apt-get remove --purge mysql-server mysql-client mysql-common
1)首先使用--sudo apt-get remove --purge mysql-server mysql-client mysql-common删除已经安装的mysql-server
2)Then clean all files sudo apt-get autoremove
2)然后清理所有文件 sudo apt-get autoremove
3)Then install mysql-server -- sudo apt-get remove -f mysql-server
3)然后安装mysql-server -- sudo apt-get remove -f mysql-server
4)Start mysql server-- sudo systemctl start mysql
4)启动mysql服务器——sudo systemctl start mysql
5)Check status of mysql-server-- systemctl status mysql
5)检查mysql-server的状态--systemctl status mysql
回答by coderodour
Stop mysql service:
停止mysql服务:
sudo service mysql stop
Remove mysql:
删除mysql:
sudo apt-get remove mysql
sudo apt-get purge mysql
Then issue a whereis mysql
command in terminal and remove all of the locations that command lists using rm -rf
command. For example rm -rf /etc/mysql
.
然后whereis mysql
在终端中发出命令并使用rm -rf
命令删除命令列出的所有位置。例如rm -rf /etc/mysql
。
Then reinstall the version of mysql you desire. All should work as expected.
然后重新安装你想要的mysql版本。一切都应该按预期工作。
回答by Venky
Just check if you db has been given the rights to write the logs give it the logs writing rights and this will get resolved .
只需检查您的数据库是否已被授予写入日志的权限,为其授予日志写入权限,这将得到解决。