在ubuntu 18.04中安装mysql的问题

我升级操作系统后安装了mysql.但是root密码似乎有问题.我试图在网上以多种方式解决这个问题,到目前为止还没有成功.

systemctl status mysql.service给出:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-05-02 16:57:24 +07; 13s ago
  Process: 6172 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=217/USER)
Thg 5 02 16:57:24 thiennguyen systemd[1]: mysql.service: Service hold-off time  over, scheduling restart.
Thg 5 02 16:57:24 thiennguyen systemd[1]: mysql.service: Scheduled restart job,  restart counter is at 5.
Thg 5 02 16:57:24 thiennguyen systemd[1]: Stopped MySQL Community Server.
Thg 5 02 16:57:24 thiennguyen systemd[1]: mysql.service: Start request repeated too quickly
Thg 5 02 16:57:24 thiennguyen systemd[1]: mysql.service: Failed with result 'exit-code'.
Thg 5 02 16:57:24 thiennguyen systemd[1]: Failed to start MySQL Community Server

journalctl -xe给:
http://codepad.org/6EbGVu2Q

mysql_secure_installation给出:

Securing the MySQL server deployment.
Enter password for user root: 
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

mysql -u root -p给出:

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

特别是当我安装时,mysql不需要为root设置密码,我已经重新安装了很多次.
也许这个问题已经过时了,但我在网络上找到了很多方法却无法解决,所以期待有所帮助.

解决方法:

您必须在安全安装时更改MySQL的旧密码.如果您不记得旧密码,请尝试通过root权限进行以下操作: –

停止MySQL服务.

service mysql stop

无需密码和权限检查即可启动MySQL.

mysqld_safe --skip-grant-tables &

连接到MySQL

mysql -u root mysql

执行以下命令,为root用户设置新密码.

UPDATE user SET password=PASSWORD('NEW_PASSWORD') WHERE user='root';
FLUSH PRIVILEGES;
service mysql restart
上一篇:java – 在samsung mobile中安装j2me应用程序


下一篇:java – 端口8086和8009的Tomcat v7.0服务器设置