美文网首页
mac10.14安装mysql5.7.25

mac10.14安装mysql5.7.25

作者: 嘴炮与实力不相符 | 来源:发表于2019-04-11 18:39 被阅读0次

    1、删除mysql的命令

    sudo rm /usr/local/mysql

    sudo rm -rf /usr/local/mysql*

    sudo rm -rf /Library/StartupItems/MySQLCOM

    sudo rm -rf /Library/PreferencePanes/My*

    sudo rm -rf /Library/Receipts/mysql*

    sudo rm -rf /Library/Receipts/MySQL*

    sudo rm -rf /var/db/receipts/com.mysql.*

    2、下载mysql

    https://dev.mysql.com/downloads/mysql/5.7.html#downloads

    选择下载

    3、安装mysql

    双击安装

    选择继续

    选择同意

    选择安装

    输入密码,选择安装

    安装安装,弹出对话框,记住root密码,选择OK,安装成功,选择关闭

    4、启动mysql

    从launchpad中启动偏好设置

    选择点击mysql

    启动mysql

    5、登入mysql

    1)从launchpad中启动终端

    执行sudo su,输入密码

    使用vi .bash_profile编辑环境环境变量

    export MYSQL_HOME=/usr/local/mysql/

    export PATH=$PATH:$MYSQL_HOME/bin

    使用source .bash_profile命令立即生效环境变量

    (2)使用命令登入密码不对:

    sh-3.2# mysql -uroot -p

    Enter password:

    ERROR 1045(28000): Access denied for user 'root'@'localhost'(using password: YES)

    3)设置不需要密码登入

    sudo cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

    发现并没有/usr/local/mysql/support-files/my-small.cnf这个文件。

    我们自己使用vi /ect/my.cnf创建文件 下面是创建的文件内容。

    #skip-grant-tables将注释去掉。

    [client]

    port = 3306

    default-character-set=utf8mb4

    socket=/tmp/mysql.sock

    [mysql]

    port = 3306

    default-character-set=utf8mb4

    socket=/tmp/mysql.sock

    [mysqld]

    ##########################

    # summary

    ##########################

    bind-address = 0.0.0.0

    port = 3306

    basedir=/usr/local/mysql

    datadir=/data/mysql

    socket=/tmp/mysql.sock

    tmpdir = /tmp

    pid-file=/tmp/mysqld.pid

    #skip-grant-tables

    #skip-networking

    explicit_defaults_for_timestamp=1

    lower_case_table_names=1

    table_open_cache = 8000

    ##########################

    # time out

    ##########################

    connect_timeout = 20

    wait_timeout = 86400

    ##########################

    # connection

    ##########################

    max_connections = 2000

    max_user_connections = 1900

    max_connect_errors = 100000

    max_allowed_packet = 1G

    ##########################

    # character set

    ##########################

    character-set-server = utf8mb4

    collation-server = utf8mb4_bin

    ##########################

    # log bin

    ##########################

    server-id = 1

    log_bin = mysql-bin

    # ROW、STATEMENT、MIXED

    binlog_format = row

    sync_binlog = 1

    expire_logs_days = 7

    binlog_cache_size = 128m

    max_binlog_cache_size = 512m

    max_binlog_size = 256M

    master_info_repository=TABLE

    relay_log_info_repository=TABLE

    log_slave_updates=ON

    binlog_checksum=none

    binlog_ignore_db=mysql

    binlog_ignore_db=information_schema

    binlog_ignore_db=performation_schema

    binlog_ignore_db=sys

    ##########################

    # gtid

    ##########################

    gtid_mode = on

    enforce_gtid_consistency = on

    ##########################

    # log relay

    ##########################

    relay_log = mysql-relay-bin

    relay_log_purge = on

    relay_log_recovery = on

    max_relay_log_size = 1G

    ##########################

    # log error

    ##########################

    log_error=/data/mysql/mysqld_error.log

    ##########################

    # log slow

    ##########################

    slow_query_log = on

    slow_query_log_file = /data/mysql/mysqld_slow.log

    long_query_time = 2

    log_queries_not_using_indexes = on

    ##########################

    # log general

    ##########################

    general_log = on

    general_log_file = /data/mysql/mysqld_gener.log

    ##########################

    # thread pool

    ##########################

    #thread_handling=pool-of-threads

    #thread_handling=one-thread-per-connection

    #thread_pool_oversubscribe=8

    ##########################

    # innodb

    ##########################

    innodb_file_per_table=1

    innodb_log_file_size=1024M

    innodb_log_buffer_size=64M

    ##########################

    # password policy

    # after init

    ##########################

    #validate_password_length=4       

    #validate_password_mixed_case_count=0

    #validate_password_number_count=0

    #validate_password_policy=0

    #validate_password_special_char_count=0

    重启mysql

    通过终端登入mysql

    (4)使用sql来修改mysql root密码

    use mysql;

    update user  set authentication_string =password("密码")where user='root';

    flush privileges;

    quit;

    (5)使用 mysql -uroot -p

    相关文章

      网友评论

          本文标题:mac10.14安装mysql5.7.25

          本文链接:https://www.haomeiwen.com/subject/bvuxwqtx.html