zoukankan      html  css  js  c++  java
  • Mac

    本文转自:

    https://gongyuhonglou.github.io

    在终端输入mysql,结果出现

    macdeMacBook-Pro:~ mac$ alias mysql=/usr/local/mysql/bin/mysql
    macdeMacBook-Pro:~ mac$ mysql
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    在网上搜到很多方法,不好使,然后查询了官方文档

    http://dev.mysql.com/doc/refman/5.7/en/can-not-connect-to-server.html

    下面写道

    Here are some reasons the Can't connect to local MySQL server error might occur:

    • mysqld is not running on the local host. Check your operating system's process list to ensure the mysqld process is present.

    • 。。。

    没想到第一条就符合,然后我尝试输入mysqld

    结果: 

    macdeMacBook-Pro:bin mac$ mysqld
    2018-05-10T07:23:29.997151Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2018-05-10T07:23:29.997492Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
    2018-05-10T07:23:29.997557Z 0 [Note] mysqld (mysqld 5.7.22) starting as process 33939 ...
    2018-05-10T07:23:30.003105Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
    2018-05-10T07:23:30.004893Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2018-05-10T07:23:30.004919Z 0 [Note] InnoDB: Uses event mutexes
    2018-05-10T07:23:30.004926Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
    2018-05-10T07:23:30.004932Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2018-05-10T07:23:30.005337Z 0 [Note] InnoDB: Number of pools: 1
    2018-05-10T07:23:30.005498Z 0 [Note] InnoDB: Using CPU crc32 instructions
    2018-05-10T07:23:30.007117Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
    2018-05-10T07:23:30.018796Z 0 [Note] InnoDB: Completed initialization of buffer pool
    2018-05-10T07:23:30.035212Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
    2018-05-10T07:23:30.051578Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
    2018-05-10T07:23:30.051764Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
    2018-05-10T07:23:30.065007Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
    2018-05-10T07:23:30.065856Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
    2018-05-10T07:23:30.065868Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
    2018-05-10T07:23:30.066135Z 0 [Note] InnoDB: Waiting for purge to start
    2018-05-10T07:23:30.121419Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 2551674
    2018-05-10T07:23:30.121762Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
    2018-05-10T07:23:30.122048Z 0 [Note] Plugin 'FEDERATED' is disabled.
    2018-05-10T07:23:30.133391Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180510 15:23:30
    2018-05-10T07:23:30.134352Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
    2018-05-10T07:23:30.134366Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
    2018-05-10T07:23:30.135842Z 0 [Warning] CA certificate ca.pem is self signed.
    2018-05-10T07:23:30.135903Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
    2018-05-10T07:23:30.142139Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
    2018-05-10T07:23:30.142191Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
    2018-05-10T07:23:30.142330Z 0 [Note] Server socket created on IP: '127.0.0.1'.
    2018-05-10T07:23:30.195770Z 0 [Note] Event Scheduler: Loaded 0 events
    2018-05-10T07:23:30.195949Z 0 [Note] mysqld: ready for connections.
    Version: '5.7.22'  socket: '/tmp/mysql.sock'  port: 3306  Homebrew

    等一大串错误之类的 ,最后退出了

    最后,正确的方法:

    macdeMacBook-Pro:~ mac$ sudo mysqld_safe
    Password:
    Logging to '/usr/local/var/mysql/macdeMacBook-Pro.local.err'.
    2018-05-10T07:14:22.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
    2018-05-10T07:14:22.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/macdeMacBook-Pro.local.pid ended
    macdeMacBook-Pro:~ mac$ mysql
    ERROR 1045 (28000): Access denied for user 'mac'@'localhost' (using password: NO)

    然后mysqld服务就运行啦

    mysql -uroot -p

    此时,终于能够打开mysql

  • 相关阅读:
    leetcode-788-Rotated Digits(使用vector替代if else的逐个判断)
    leetcode-771-Jewels and Stones(建立哈希表,降低时间复杂度)
    leetcode-766-Toeplitz Matrix(每一条对角线元素的比较)
    leetcode-762-Prime Number of Set Bits in Binary Representation
    leetcode-747-Largest Number At Least Twice of Others(求vector的最大值和次大值)
    Flink中逻辑计划和物理计划的概念划分和对应关系
    Java线程池中线程的生命周期
    在ServletFilter层返回多字段提示给前端
    JavaBIO利用装饰器模式来组织和扩展接口
    SparkShuffle机制
  • 原文地址:https://www.cnblogs.com/minmin123/p/11529393.html
Copyright © 2011-2022 走看看