2

使用默认值安装,我已经安装了mysql 5.7.13。使用此处的说明从源代码: https
://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html 然后我按照此处的说明初始化数据目录:https://dev.mysql .com/doc/refman/5.7/en/data-directory-initialization.html
这安装在我的 ubuntu 14.04 服务器上。

使用这个启动服务器:

bin/mysqld_safe --user=mysql &

告诉我检查日志文件 error.log。Error.log 说

2016-07-15T22:16:43.460297Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2016-07-15T22:16:43.862401Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see$
2016-07-15T22:16:43.863013Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider$
2016-07-15T22:16:43.863502Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.13) starting as process 1996 ...
2016-07-15T22:16:43.864532Z 0 [ERROR] Can't find error-message file '/usr/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' c$
2016-07-15T22:16:43.893029Z 0 [Note] InnoDB: PUNCH HOLE support available
2016-07-15T22:16:43.893057Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-15T22:16:43.893080Z 0 [Note] InnoDB: Uses event mutexes
2016-07-15T22:16:43.893084Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2016-07-15T22:16:43.893086Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-07-15T22:16:43.894664Z 0 [Note] InnoDB: Number of pools: 1
2016-07-15T22:16:43.902772Z 0 [Note] InnoDB: Using CPU crc32 instructions
2016-07-15T22:16:43.908310Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2016-07-15T22:16:43.932802Z 0 [Note] InnoDB: Completed initialization of buffer pool
2016-07-15T22:16:43.942146Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of se$
2016-07-15T22:16:43.952791Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2016-07-15T22:16:43.952931Z 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2016-07-15T22:16:44.015448Z 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2016-07-15T22:16:44.015683Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-07-15T22:16:44.197808Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-07-15T22:16:44.296354Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-07-15T22:16:44.296394Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-07-15T22:16:44.296404Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2016-07-15T22:16:44.296422Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2016-07-15T22:16:44.319575Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2016-07-15T22:16:44.319763Z 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-07-15T22:16:44.340836Z 0 [Note] InnoDB: Doublewrite buffer created
2016-07-15T22:16:44.345684Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2016-07-15T22:16:44.345696Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2016-07-15T22:16:44.345779Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-07-15T22:16:44.353886Z 0 [Note] InnoDB: Foreign key constraint system tables created
2016-07-15T22:16:44.353917Z 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-07-15T22:16:44.354865Z 0 [Note] InnoDB: Tablespace and datafile system tables created.
2016-07-15T22:16:44.354886Z 0 [Note] InnoDB: Creating sys_virtual system tables.
2016-07-15T22:16:44.355467Z 0 [Note] InnoDB: sys_virtual table created
2016-07-15T22:16:44.356452Z 0 [Note] InnoDB: Waiting for purge to start
2016-07-15T22:16:44.406828Z 0 [Note] InnoDB: 5.7.13 started; log sequence number 0
2016-07-15T22:16:44.406972Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Unknown error 1146
2016-07-15T22:16:44.408277Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-07-15T22:16:44.408377Z 0 [ERROR] unknown variable 'key_buffer=16M'
2016-07-15T22:16:44.408381Z 0 [ERROR] Aborting


2016-07-15T22:16:44.408393Z 0 [Note] Binlog end
2016-07-15T22:16:44.408425Z 0 [Note] Shutting down plugin 'ngram'
2016-07-15T22:16:44.408428Z 0 [Note] Shutting down plugin 'partition'
2016-07-15T22:16:44.408430Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2016-07-15T22:16:44.408433Z 0 [Note] Shutting down plugin 'ARCHIVE'
2016-07-15T22:16:44.408435Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-07-15T22:16:44.408477Z 0 [Note] Shutting down plugin 'MEMORY'
2016-07-15T22:16:44.408480Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2016-07-15T22:16:44.408482Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-07-15T22:16:44.408483Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-07-15T22:16:44.408485Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2016-07-15T22:16:44.408486Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2016-07-15T22:16:44.408488Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2016-07-15T22:16:44.408490Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2016-07-15T22:16:44.408491Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2016-07-15T22:16:44.408493Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2016-07-15T22:16:44.408494Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2016-07-15T22:16:44.408496Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2016-07-15T22:16:44.408497Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2016-07-15T22:16:44.408499Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2016-07-15T22:16:44.408500Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2016-07-15T22:16:44.408502Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2016-07-15T22:16:44.408503Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2016-07-15T22:16:44.408505Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2016-07-15T22:16:44.408506Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2016-07-15T22:16:44.408508Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2016-07-15T22:16:44.408510Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2016-07-15T22:16:44.408511Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2016-07-15T22:16:44.408513Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2016-07-15T22:16:44.408514Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2016-07-15T22:16:44.408516Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2016-07-15T22:16:44.408517Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2016-07-15T22:16:44.408519Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2016-07-15T22:16:44.408520Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2016-07-15T22:16:44.408522Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2016-07-15T22:16:44.408523Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2016-07-15T22:16:44.408525Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2016-07-15T22:16:44.408526Z 0 [Note] Shutting down plugin 'InnoDB'
2016-07-15T22:16:44.408548Z 0 [Note] InnoDB: FTS optimize thread exiting.

并启动 mysql_updgrade

bin/mysql_upgrade

我收到一条错误消息:

mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connection to MySQL server Upgrade process遇到错误,不会继续。

问题是 sock 文件在任何地方都不存在。它只是不存在。我已经使用findand进行了搜索,locate并且我 100% 确定它不在我的服务器上。看着my.cnf/etc/mysql/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.
[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[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            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer              = 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         = BACKUP
#max_connections        = 100
#table_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
#log_slow_queries       = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#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



[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer              = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
[isamchk]
key_buffer              = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

这些默认值都不正确。所以我更改了我的 my.cnf 文件,以适当地匹配所有内容。由于 mySQL 安装在 /usr/local/mysql 中。

更改了 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.

[client]
#host           = 127.0.0.1
port            = 3306
socket          = /tmp/mysql.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          = /tmp/mysql.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /tmp/mysqld.pid
socket          = /tmp/mysqld.sock
port            = 3306
basedir         = /usr/local/mysql
datadir         = /usr/local/mysql/data
tmpdir          = /tmp
lc-messages-dir = /usr/local/mysql/share
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            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer              = 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         = BACKUP
#max_connections        = 100
#table_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 = /usr/local/mysql/data/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries       = /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



[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer              = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

现在,我仍然遇到同样的问题。无论我说 my.cnf 位于哪个文件夹以及具有哪些权限,都不会创建套接字文件。我曾尝试创建文件本身,但它会产生相同的结果。
是的,我确保 my.cnf 是 mySQL 的默认文件。该端口在 iptables 中打开,并且 mySQL 用户确实拥有/访问 mysql 配置指向的所有文件的所有权/访问权限。

我在安装了 apache2 的 Ubuntu 14.04 服务器上运行它。并且服务器在 Virtual Box 中运行。我正在通过 Putty 访问服务器。

我已经坚持了好几天了,在尝试了我可以在本网站和其他网站上的其他问题中找到的所有解决方案之后,我完全不知道该怎么做。我可以提供帮助回答这个问题所需的任何和所有信息/日志。

我真的很感激在这个问题上的任何帮助!

4

1 回答 1

1

我解决了这个问题。error.log 中有一行关于我忽略的密钥缓冲区大小。注释掉这两行之后:

#myisam-recover = BACKUP
#key_buffer = 16M

我删除了默认数据目录并重新初始化了数据目录。然后Mysql启动没有问题。

于 2016-07-16T01:53:25.063 回答