在全新的 Kubuntu 14.04 安装上,我运行了sudo aptitude install mysql-server-core-5.6
. 由于某些 KDE 软件包对 的依赖,安装无法完成,mysql-server-core-5.5
这些软件包将被替换。现在,当我运行时sudo aptitude install mysql-server-5.5
,指定密码后出现此错误:
Configuring mysql-server-5.5
Unable to set password for the MySQL "root" user
An error occurred while setting the password for the MySQL administrative user. This may have happened
because the account already has a password, or because of a communication problem with the MySQL server.
You should check the account's password after the package installation.
Please read the /usr/share/doc/mysql-server-5.5/README.Debian file for more information.
我实际上已经阅读过/usr/share/doc/mysql-server-5.5/README.Debian
,但与我的情况无关。MySQL 日志有助于:
$ tail /var/log/mysql/error.log
140818 10:17:16 InnoDB: Completed initialization of buffer pool
140818 10:17:16 InnoDB: highest supported file format is Barracuda.
140818 10:17:16 InnoDB: Waiting for the background threads to start
140818 10:17:17 InnoDB: 5.5.38 started; log sequence number 1595675
140818 10:17:17 [ERROR] /usr/sbin/mysqld: unknown option '--explicit_defaults_for_timestamp'
140818 10:17:17 [ERROR] Aborting
140818 10:17:17 InnoDB: Starting shutdown...
140818 10:17:18 InnoDB: Shutdown completed; log sequence number 1595675
140818 10:17:18 [Note]
但是我找不到在哪个脚本--explicit_defaults_for_timestamp
中设置了该选项。我试图在mysql
没有service
避免该--explicit_defaults_for_timestamp
选项的情况下启动,但它仍然无法启动:
$ ps aux | grep mysql
dotanco+ 25458 0.0 0.0 11748 928 pts/4 S+ 10:30 0:00 grep --color=auto mysql
$ sudo mysqld_safe --skip-grant-tables &
[1] 25470
140818 10:30:54 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
140818 10:30:54 mysqld_safe Logging to '/var/log/mysql/error.log'.
140818 10:30:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140818 10:30:57 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[1]+ Done sudo mysqld_safe --skip-grant-tables
$ ps aux | grep mysql
dotanco+ 25810 0.0 0.0 11748 932 pts/4 S+ 10:31 0:00 grep --color=auto mysql
错误告诉我Remove all --log-error configuration options
。因此,我编辑/etc/mysql/my.cnf
并注释掉了以下行:
log-error = /var/log/mysql/error.log
现在我没有收到错误但仍然无法登录:
$ sudo mysqld_safe --skip-grant-tables &
[1] 26558
140818 10:34:37 mysqld_safe Logging to syslog.
140818 10:34:38 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140818 10:34:40 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[1]+ Done sudo mysqld_safe --skip-grant-tables
$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
可能是什么问题?我应该如何进行?
编辑
我现在已经注释掉explicit-defaults-for-timestamp
了my.cnf
. 这是整个文件,减去标题注释:
$ cat /etc/mysql/my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
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
#explicit_defaults_for_timestamp
bind-address = 127.0.0.1
#log-error = /var/log/mysql/error.log
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
!includedir /etc/mysql/conf.d/
这是我尝试运行 MySQL 时发生的情况:
$ sudo echo 1 >> /var/log/mysql/error.log
$ tail /var/log/mysql/error.log
140818 10:31:49 InnoDB: Waiting for the background threads to start
140818 10:31:50 InnoDB: 5.5.38 started; log sequence number 1595675
140818 10:31:50 [ERROR] /usr/sbin/mysqld: unknown option '--explicit_defaults_for_timestamp'
140818 10:31:50 [ERROR] Aborting
140818 10:31:50 InnoDB: Starting shutdown...
140818 10:31:51 InnoDB: Shutdown completed; log sequence number 1595675
140818 10:31:51 [Note]
140818 10:31:51 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
1
$ sudo service mysql start
start: Job failed to start
$ tail /var/log/mysql/error.log
140818 10:31:49 InnoDB: Waiting for the background threads to start
140818 10:31:50 InnoDB: 5.5.38 started; log sequence number 1595675
140818 10:31:50 [ERROR] /usr/sbin/mysqld: unknown option '--explicit_defaults_for_timestamp'
140818 10:31:50 [ERROR] Aborting
140818 10:31:50 InnoDB: Starting shutdown...
140818 10:31:51 InnoDB: Shutdown completed; log sequence number 1595675
140818 10:31:51 [Note]
140818 10:31:51 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
1
$ grep explicit_defaults_for_timestamp /etc/mysql/my.cnf /etc/init.d/mysql /etc/default/mysql
/etc/mysql/my.cnf:#explicit_defaults_for_timestamp
grep: /etc/default/mysql: No such file or directory
可以看出,日志中没有写入任何新内容,explicit_defaults_for_timestamp
也没有在任何地方设置该选项。
我能够重新安装mysql-server-core-5.5
,但这并没有解决问题:
$ sudo aptitude reinstall mysql-server-core-5.5
The following packages will be REINSTALLED:
mysql-server-core-5.5
0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 3,213 kB of archives. After unpacking 0 B will be used.
Get: 1 http://il.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 amd64 5.5.38-0ubuntu0.14.04.1 [3,213 kB]
Fetched 3,213 kB in 1s (3,163 kB/s)
(Reading database ... 217167 files and directories currently installed.)
Preparing to unpack .../mysql-server-core-5.5_5.5.38-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-server-core-5.5 (5.5.38-0ubuntu0.14.04.1) over (5.5.38-0ubuntu0.14.04.1) ...
Replaced by files in installed package mysql-common (5.6.20-1ubuntu14.04) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up mysql-server-core-5.5 (5.5.38-0ubuntu0.14.04.1) ...
$ sudo service mysql status
mysql stop/waiting
$ sudo service mysql start
start: Job failed to start
$ tail /var/log/mysql/error.log
140818 10:31:49 InnoDB: Waiting for the background threads to start
140818 10:31:50 InnoDB: 5.5.38 started; log sequence number 1595675
140818 10:31:50 [ERROR] /usr/sbin/mysqld: unknown option '--explicit_defaults_for_timestamp'
140818 10:31:50 [ERROR] Aborting
140818 10:31:50 InnoDB: Starting shutdown...
140818 10:31:51 InnoDB: Shutdown completed; log sequence number 1595675
140818 10:31:51 [Note]
140818 10:31:51 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
1
1
日志最后一行的那个是之前添加的,表示日志中echo
没有添加任何新内容。
您安装了
mysql-server-core-5.6
,其中部分失败或部分安装。-explicit_defaults_for_timestamp
仅适用于 MySQL 5.6 。可能是部分安装mysql-server-core-5.6
添加了此选项。我现在建议您删除任何痕迹mysql-server-core-5.6
并重新初始化数据目录。杀死任何正在运行的 mysqld 进程:
卸载
mysql-server-core-5.6
软件包:文件列表在这里
重新初始化数据库目录:
一个。
rm -Rf /var/lib/mysql/*
B.
mysql_install_db /var/lib/mysql
注释掉里面的
!includedir /etc/mysql/conf.d/
选项my.cnf
杀死任何现有的 MySQL 进程,然后使用该
skip-grant-tables
选项启动 MySQL。A. 获取 mysqld 守护进程的准确路径:
B. 在没有授权表的情况下运行 MySQL:
C. 确保 mysql 正在监听:
您应该看到端口 3306。
D. 如果是,登录 MySQL:
E. 设置新密码:
我在 my.cnf 中有这一行
我认为 my.cnf 参数应该使用连字符而不是下划线。