在Ubuntu 16.04上安装mySql时出错


15

我一直按照此页面 上的说明在Ubuntu 16.04上安装mysql。

我在标题为“ MySQL Install and Configure”的页面的下半部分运行了命令sudo apt-get install mysql-server。我遇到了一个错误,但这是我的终端中该错误的输出:

Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 41515 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-common (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.12-0ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-common (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 41563 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-client-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
mysql_upgrade: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 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
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

这是我第一次设置服务器并安装mysql。不知道这是否可能是错误的可能原因,但是我以前曾尝试安装mysql,但未遵循LAMP进程(我是newb弄清楚了这一点),但未成功,我必须卸载。


欢迎来到AskUbuntu。在您的日志中有一行Access denied for user 'debian-sys-maint'@'localhost'。该用户来自哪里?我不希望在Ubuntu系统上找到它。
贡伯特'16

您好甘特伯特-稍作搜索,似乎它的debian.cnf文件了。我找到了这个stackoverflow.com/questions/11644300/…- 并查看得到47分(不是可接受的答案)的答案,密码不匹配。我正在试一试-不成功,因为我不知道密码是什么!
达伦·海恩斯

此答案无需清除mysql就可以解决我的问题:https
//askubuntu.com/a/793545/597698

Answers:


17

此答案也是针对16.04升级破坏了mysql-server的回答,但由于管理员将其锁定为10个信誉,因此我无法回答。

在Ubuntu升级到16.04(xenial)以及将Mysql从5.5升级到5.7的过程中,会发生APT中的错误。由于某些打包问题,由于Mysql-server-5.7的安装后脚本无法完成,APT升级最终陷入僵局。

要解决此问题,请尝试以下步骤:

  1. apt purge mysql-serverapt autoremove清除旧MYSQL的所有痕迹。数据库数据将不会被破坏。
  2. /etc/mysql目录中删除所有内容。
  3. 确认没有剩余的旧MySQL软件包安装: dpkg -l | grep mysql
  4. apt install mysql-server 安装

如果这些步骤以相同的不完整安装结束,请尝试下一步:

  1. Tail -n 20 /var/log/mysql/error.log
  2. 错误可能是 debian-sys-maint的错误密码b。没有内存为Innodb

解决方案2a:您需要将Mysql系统表从5.5升级到5.7

编辑my.cnf,使其在“ [mysqld]”下包含“ skip-grant-tables”行service mysql start,以及mysql_upgrade --force -u root -p

解决方案2b:Mysql Innodb池的内存不足(您在微型服务器上吗?)

编辑my.cnf以在'[mysqld]'下包含innodb_buffer_pool_size = 20M行

默认的innodb池为128M,在512M VM中是紧密的

要清除APT错误,请再次进行后期安装

dpkg --configure -a

它将删除数据库还是将保持安全?
的Thirumal

5

最终我完全解决了完全删除mysql并重新安装的问题。尽管我曾经尝试卸载并重新安装一次,但都失败了(这使我提出了这个问题)。在找到此页面上的建议后,我尝试了更彻底的卸载: 完全卸载MySQL

按照此处的卸载说明进行重新安装即可解决此问题。



3

这为我工作:

sudo apt-get remove --purge mysql*

该命令将询问您是否要 要从中删除数据库/var/lib/mysql还将删除所有其他mysql实例!

所以 ,请首先对您的数据库进行备份

之后,我可以通过发出命令来安装数据库:

sudo apt-get install mysql-server

1

尝试删除所有软件包和文件,然后重新安装“ mysql-server”

sudo apt-get remove --purge mysql-\*
sudo rm -rf /var/lib/mysql

sudo apt-get install mysql-server 

1

首先,您删除了mysql-server的所有软件包:

sudo rm -rf /var/lib/mysql

然后安装:

sudo apt-get install lamp-server^

或者,您可以执行以下操作:

sudo apt-get install mysql-server

1
请不要不rm -rf 说此命令将破坏什么样的信息而发布。
布赖恩·伍
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.