今天連本地數據庫,報沒法鏈接的錯mysql
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
查詢資料,說是要把mysql的配置文件中的bind-address註釋調sql
# bind-address = 127.0.0.1
而後重啓便可。數據庫
然而在重啓時報錯:ubuntu
c80k2@c80k2-Vostro-3667❯/etc/mysql/mysql.conf.d$ sudo /etc/init.d/mysql restart [....] Restarting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. failed!
c80k2@c80k2-Vostro-3667❯/etc/mysql/mysql.conf.d$ sudo service mysql restart Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
提示查看"systemctl status mysql.service" and "journalctl -xe" 獲取詳情。vim
c80k2@c80k2-Vostro-3667❯/etc/mysql/mysql.conf.d$ systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: activating (start-post) (Result: exit-code) since 二 2018-03-06 10:42:52 CST; 19s ago Process: 23472 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE) Process: 23464 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 23472 (code=exited, status=1/FAILURE); : 23473 (mysql-systemd-s) CGroup: /system.slice/mysql.service └─control ├─23473 /bin/bash /usr/share/mysql/mysql-systemd-start post └─23516 sleep 1 3月 06 10:42:52 c80k2-Vostro-3667 systemd[1]: Starting MySQL Community Server... 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:52.949388Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:52.949501Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000) 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:53.097114Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:53.098086Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21-0ubuntu0.16.04.1-log) starting as process 23472 ... 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:53.099329Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server s 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:53.099344Z 0 [ERROR] Aborting 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:53.099356Z 0 [Note] Binlog end 3月 06 10:42:53 c80k2-Vostro-3667 mysqld[23472]: 2018-03-06T02:42:53.099385Z 0 [Note] /usr/sbin/mysqld: Shutdown complete 3月 06 10:42:53 c80k2-Vostro-3667 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE ESCOC
看到有這麼一句:You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server s...bash
你已經開啓了binary log日誌,可是沒有提供強制的server-id.ide
進mysql配置文件 vim /etc/mysql/mysql.conf.d/mysqld.conf,將server-id打開post
server-id = 1
再次重啓mysql便可使用。rest