简体   繁体   中英

Mysql installation error:Unable to set password for the MySQL “root” user

Many people have encountered this error,but no provided solutions work for my case:

In my ubuntu 14.04 server,mysql-server 5.5 works fine,and for some reason,two of our guys tried to upgrade to 5.6,after some messing operations,they failed,only 5.6-client,and mysql-commn got installed,so I actually don't know their detailed operations,then I tried to downgrade back to 5.5 like this:

killall -9 mysql
killall -9 mysqld
apt-get purge mysql-*
remove /etc/myql
apt-get install mysql-sever-5.5

got an error:

 ┌───────────────────────Configuring mysql-server-5.5─────────────────────────┐ 
 │ Unable to set password for the MySQL "root" user                           │ 
 ├────────────────────────────────────────────────────────────────────────────┤

and installation log like this:

Setting up mysql-server-core-5.5 (5.5.54-0ubuntu0.14.04.1) ...
Setting up mysql-server-5.5 (5.5.54-0ubuntu0.14.04.1) ...
170218  2:15:57 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
170218  2:15:57 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170218  2:15:57 [Note] /usr/sbin/mysqld (mysqld 5.5.54-0ubuntu0.14.04.1) starting as process 9038 ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Errors were encountered while processing:
 mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)

error log like this:

 170218  2:15:57 [ERROR] /usr/sbin/mysqld: Incorrect information in file: './mysql/tables_priv.frm'
ERROR: 1033  Incorrect information in file: './mysql/tables_priv.frm'
170218  2:15:57 [ERROR] Aborting

170218  2:15:57 [Note] /usr/sbin/mysqld: Shutdown complete

170218  2:15:57 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and
 will be removed in a future release. Please use the full name instead.
170218  2:15:57 [Note] Plugin 'FEDERATED' is disabled.
170218  2:15:57 InnoDB: The InnoDB memory heap is disabled
170218  2:15:57 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170218  2:15:57 InnoDB: Compressed tables use zlib 1.2.8
170218  2:15:57 InnoDB: Using Linux native AIO
170218  2:15:57 InnoDB: Initializing buffer pool, size = 128.0M
170218  2:15:57 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
170218  2:15:57 [ERROR] Plugin 'InnoDB' init function returned error.
170218  2:15:57 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170218  2:15:57 [ERROR] Unknown/unsupported storage engine: InnoDB
170218  2:15:57 [ERROR] Aborting

170218  2:15:57 [Note] /usr/sbin/mysqld: Shutdown complete

So,how to solve this problem?Any suggestion is appreciated?

Do this:

sudo -i
service mysql stop
killall -KILL mysql mysqld_safe mysqld
apt-get --yes purge mysql-server mysql-client
apt-get --yes autoremove --purge
apt-get autoclean
deluser --remove-home mysql
delgroup mysql
rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld /etc/mysql /var/lib/mysql /var/log/mysql* /var/log/upstart/mysql.log* /var/run/mysqld
updatedb
exit

You may also need dpkg -l | grep mysql dpkg -l | grep mysql to list any installed mysql packages, then eg sudo apt-get purge mysql-common for each entry.

If above steps are done and no mysql references are there when dpkg -l | grep mysql dpkg -l | grep mysql is run you can try installing with following command:

sudo apt-get install mysql-server-5.5

I'm facing the same issue installing the version 5.6 of MySQL in Ubuntu 16.04 LTS. After searching and talking with friends I figured out how install this without errors.

First backup your databases and follow this commands:

$ sudo apt-get remove --purge *mysql/*
$ sudo apt-get autoremove
$ sudo apt-get autoclean
$ sudo rm -rf /var/lib/mysql
$ sudo apt install mysql-server-5.6
$ sudo apt install mysql-client-5.6

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM