当先锋百科网

首页 1 2 3 4 5 6 7

安装MySQL最后一步,输入命令:

sudo dpkg -i mysql-{common,community-client,client,community-server,server}_*.deb

输出:

(Reading database ...  files and directories currently installed.)
Preparing to unpack mysql-common_5.7.17-1ubuntu16.10_amd64.deb ...
Unpacking mysql-common (-1ubuntu16.10) over (-1ubuntu16.10) ...
Preparing to unpack mysql-community-client_5.7.17-1ubuntu16.10_amd64.deb ...
Unpacking mysql-community-client (-1ubuntu16.10) over (-1ubuntu16.10) ...
Preparing to unpack mysql-client_5.7.17-1ubuntu16.10_amd64.deb ...
Unpacking mysql-client (-1ubuntu16.10) over (-1ubuntu16.10) ...
Selecting previously unselected package mysql-community-server.
Preparing to unpack mysql-community-server_5.7.17-1ubuntu16.10_amd64.deb ...
Unpacking mysql-community-server (-1ubuntu16.10) ...
Selecting previously unselected package mysql-server.
Preparing to unpack mysql-server_5.7.17-1ubuntu16.10_amd64.deb ...
Unpacking mysql-server (-1ubuntu16.10) ...
Setting up mysql-common (-1ubuntu16.10) ...
Setting up mysql-community-client (-1ubuntu16.10) ...
Setting up mysql-client (-1ubuntu16.10) ...
dpkg: dependency problems prevent configuration of mysql-community-server:
 mysql-community-server depends on libmecab2 (>= -); however:
  Package libmecab2 is not installed.

dpkg: error processing package mysql-community-server (--install):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-community-server (= -1ubuntu16.10); however:
  Package mysql-community-server is not configured yet.

dpkg: error processing package mysql-server (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (-) ...
Processing triggers for systemd (-4ubuntu16) ...
Processing triggers for ureadahead (-) ...
Errors were encountered while processing:
 mysql-community-server
 mysql-server

如果我们登录MySQL:

输入密码后,输出结果是:

Enter password: 
ERROR  (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' ()

解决办法:

sudo rm /var/lib/mysql/ -R
sudo rm /etc/mysql/ -R
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor #这一步选Yes
sudo apt-get install mysql-server mysql-common #重新输入密码

然后重新登录:

输入密码,输出:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 
Server version: -ubuntu0 (Ubuntu)

Copyright (c) , , Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

问题解决。