无法为mysql“root”用户设置密码

我是Ubuntu的新手。 我正在运行Ubuntu 12.10。 我正在尝试安装apache,php,mysql。 但是我已经安装了apache并且运行正常。

sudo apt-get install apache2 

但是当我尝试使用以下命令安装mysql时

 sudo apt-get install mysql-server 

下载后,它会输入并确认密码后输入密码。 我收到以下错误消息。

无法为Mysql“root”用户设置密码

设置mysql密码时出错
管理用户。这可能是因为帐户已经有密码,或者是因为Mysql服务器存在通信问题。
您应该在安装软件包后检查帐户的密码。
有关更多信息,请阅读/usr/share/doc/mysql-server-5.5/README.Debian文件。

点击提示上的确定按钮后,我在终端上收到以下消息

 Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ... start: Job failed to start invoke-rc.d: initscript mysql, action "start" failed. dpkg: error processing mysql-server-5.5 (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: mysql-server-5.5 E: Sub-process /usr/bin/dpkg returned an error code (1) 

Mysql错误日志说

 130209 14:26:37 [Note] Plugin 'FEDERATED' is disabled. 130209 14:26:37 InnoDB: The InnoDB memory heap is disabled 130209 14:26:37 InnoDB: Mutexes and rw_locks use GCC atomic builtins 130209 14:26:37 InnoDB: Compressed tables use zlib 1.2.7 130209 14:26:37 InnoDB: Using Linux native AIO mysqld: Can't create/write to file '/tmp/ibNuz7q0' (Errcode: 13) 130209 14:26:37 InnoDB: Error: unable to create temporary file; errno: 13 130209 14:26:37 [ERROR] Plugin 'InnoDB' init function returned error. 130209 14:26:37 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 130209 14:26:37 [ERROR] Unknown/unsupported storage engine: InnoDB 130209 14:26:37 [ERROR] Aborting 

我已经搜索过这个问题了,但没有什么对我有用。 请帮忙。

这里的root密码设置问题相同,可能是由于以前手动安装mysql server 5.6失败造成的。 彻底的mysql卸载绝非易事。 我清洗/重新安装了几个小时,然后终于解决了它

 sudo dpkg --purge mysql-client-core-5.5 # or alternative version sudo dpkg --purge mysql-client sudo dpkg --purge mysql-server-core-5.5 # or alternative version sudo dpkg --purge mysql-common 

基本上我只是打字

 sudo dpkg --purge mysql # followed by two tabs 

然后 – --purge终端自动完成的任何包。 最后清除mysql-common因为一些依赖性问题。

除了使用上面的dpkg命令

 sudo apt-get --purge remove mysql-server sudo apt-get --purge remove mysql-client sudo apt-get --purge remove mysql-common sudo apt-get autoremove sudo apt-get autoclean 

我也试过Greq的方法

 sudo rm -rf /etc/mysql 

从/ var / lib中删除mysql文件夹

 sudo rm -rf /var/lib/mysql/ 

此时,为了确保完全删除mysql,请检查

 which mysql mysql --version 

第一个应该不返回输出而不是文件夹。 第二个应该返回没有安装mysql而不是版本号。 否则删除仍然不完整。

dpkg --purge的意义在于,当单独使用apt-get时, which mysqlmysql --version行为就像mysql一样。

在重新安装之前,请重新配置dpkg并进行更新

 sudo dpkg --configure -a sudo apt-get update 

问题终于解决了。 希望它对其他人有所帮助。

你需要完全删除mysql。 相信我,我试过了。 dpkg不会单独这样做。

看到

https://stackoverflow.com/questions/10853004/removing-mysql-5-5-completely

如果你赶时间

 sudo service mysql stop #or mysqld sudo killall -9 mysql sudo killall -9 mysqld sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get autoremove sudo apt-get autoclean sudo deluser mysql sudo rm -rf /var/lib/mysql sudo apt-get purge mysql-server-core-5.5 sudo apt-get purge mysql-client-core-5.5 

我认为原因是mysql无法访问你的/tmp/目录,正如它在行中所说的那样

 mysqld:无法创建/写入文件'/ tmp / ibNuz7q0'(错误代码:13)

在终端中运行以下命令:

 sudo su
 chown root:root / tmp
 chmod 1777 / tmp
 / usr / sbin / mysqld&

说明

  • sudo su :以root身份运行以下命令。
  • chown root:root /tmp :将root组的root用户设为chown root:root /tmp的所有者。
  • chmod 1777 /tmp :更改chmod 1777 /tmp的权限,使其可供所有用户访问,只有所有者或root才能删除该目录中的文件。 (有关文件权限的更多信息 )
  • /usr/sbin/mysqld & :启动mysqld守护进程。

昨晚我用这个摔了几个小时,并阅读了谷歌在索引中关于这个问题的一切。

我重新安装了mysql 20次。 这可能是一个字面的数字。

最后,其中一个或两个都修复了问题(在卸载/清除/烧录mysql之后):

  1. sudo rm -rf /etc/mysql (清除后没有删除)
  2. 然后关闭服务器并将我的VM实例从512MB调整为1GB(RAM)。

之后,我运行了sudo aptitude install mysql-server ,最后成功安装:

 $ sudo aptitude install mysql-server [sudo] password for [REDACTED]: The following NEW packages will be installed: libdbd-mysql-perl{a} libmysqlclient18{a} mysql-client-5.5{a} mysql-common{a} mysql-server mysql-server-5.5{a} mysql-server-core-5.5{a} 0 packages upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 8,589 kB of archives. After unpacking 94.6 MB will be used. Do you want to continue? [Y/n/?] Y Get: 1 http://ftp.us.debian.org/debian/ wheezy/main mysql-common all 5.5.31+dfsg-0+wheezy1 [85.3 kB] Get: 2 http://ftp.us.debian.org/debian/ wheezy/main libmysqlclient18 amd64 5.5.31+dfsg-0+wheezy1 [687 kB] Get: 3 http://ftp.us.debian.org/debian/ wheezy/main libdbd-mysql-perl amd64 4.021-1+b1 [126 kB] Get: 4 http://ftp.us.debian.org/debian/ wheezy/main mysql-client-5.5 amd64 5.5.31+dfsg-0+wheezy1 [1,923 kB] Get: 5 http://ftp.us.debian.org/debian/ wheezy/main mysql-server-core-5.5 amd64 5.5.31+dfsg-0+wheezy1 [3,784 kB] Get: 6 http://ftp.us.debian.org/debian/ wheezy/main mysql-server-5.5 amd64 5.5.31+dfsg-0+wheezy1 [1,900 kB] Get: 7 http://ftp.us.debian.org/debian/ wheezy/main mysql-server all 5.5.31+dfsg-0+wheezy1 [83.6 kB] Fetched 8,589 kB in 2s (3,068 kB/s) Preconfiguring packages ... Selecting previously unselected package mysql-common. (Reading database ... 52430 files and directories currently installed.) Unpacking mysql-common (from .../mysql-common_5.5.31+dfsg-0+wheezy1_all.deb) ... Selecting previously unselected package libmysqlclient18:amd64. Unpacking libmysqlclient18:amd64 (from .../libmysqlclient18_5.5.31+dfsg-0+wheezy1_amd64.deb) ... Selecting previously unselected package libdbd-mysql-perl. Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.021-1+b1_amd64.deb) ... Selecting previously unselected package mysql-client-5.5. Unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ... Selecting previously unselected package mysql-server-core-5.5. Unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ... Processing triggers for man-db ... Setting up mysql-common (5.5.31+dfsg-0+wheezy1) ... Selecting previously unselected package mysql-server-5.5. (Reading database ... 52616 files and directories currently installed.) Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ... Selecting previously unselected package mysql-server. Unpacking mysql-server (from .../mysql-server_5.5.31+dfsg-0+wheezy1_all.deb) ... Processing triggers for man-db ... Setting up libmysqlclient18:amd64 (5.5.31+dfsg-0+wheezy1) ... Setting up libdbd-mysql-perl (4.021-1+b1) ... Setting up mysql-client-5.5 (5.5.31+dfsg-0+wheezy1) ... Setting up mysql-server-core-5.5 (5.5.31+dfsg-0+wheezy1) ... Setting up mysql-server-5.5 (5.5.31+dfsg-0+wheezy1) ... Stopping MySQL database server: mysqld. 131124 15:39:56 [Note] Plugin 'FEDERATED' is disabled. 131124 15:39:56 InnoDB: The InnoDB memory heap is disabled 131124 15:39:56 InnoDB: Mutexes and rw_locks use GCC atomic builtins 131124 15:39:56 InnoDB: Compressed tables use zlib 1.2.7 131124 15:39:56 InnoDB: Using Linux native AIO 131124 15:39:56 InnoDB: Initializing buffer pool, size = 128.0M 131124 15:39:56 InnoDB: Completed initialization of buffer pool 131124 15:39:56 InnoDB: highest supported file format is Barracuda. 131124 15:39:56 InnoDB: Waiting for the background threads to start 131124 15:39:57 InnoDB: 5.5.31 started; log sequence number 1595675 131124 15:39:57 InnoDB: Starting shutdown... 131124 15:39:58 InnoDB: Shutdown completed; log sequence number 1595675 Starting MySQL database server: mysqld .. Checking for tables which need an upgrade, are corrupt or were not closed cleanly.. Setting up mysql-server (5.5.31+dfsg-0+wheezy1) ... 

输入sudo apt-get purge mysql-server && sudo apt-get install mysql-server如果不起作用,请对我的回答发表评论,我会和你一起解决这个问题。

12.04之后的所有Ubuntu版本的安装脚本不遵循与12.04相同的设置过程。 在12.04中,明确要求您在安装期间设置mysql密码。 对于12.10以及之后它只是要求mysql root密码,但是那个密码是什么? 安装脚本向后退一步。 我建议在虚拟机中安装12.04并在那里安装mysql。 如果你像我一样使用这个与Drupal一起坚持12.04。

针对那些仍有问题的人提供不同的解 希望我能帮助那些试图重新安装Mysql的人。 注意,这是寻求和摧毁任务。 所以要疲倦。 假设你的根:

 apt-get purge mysql* apt-get purge dbconfig-common #the screen used for mysql password find / -name *mysql* #delete any traces of mysql #insert apt-get cleanups, autoremove,updates etc. 

最初,剩下的东西干扰了我启动mysqlserver-5.5。 这些命令最终解决了我自己的问题。