macOS安装和配置MySQL5.7

macOS安装和配置MySQL5.7

官方推荐的安装方法请看:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

下载最新的mysql tar.gz 包,把解压缩后的包移动到 /usr/local 目录下,

sudo mv mysql-5.7.15-osx10.11-x86_64 /usr/local/mysql

修改目录的权限

sudo chown -R xinxingegeya:wheel mysql

初始化mysql,

➜  mysql bin/mysqld --initialize --user=xinxingegeya --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2016-09-25T06:41:00.870572Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-09-25T06:41:00.880225Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2016-09-25T06:41:01.034242Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-09-25T06:41:01.060623Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-09-25T06:41:01.124713Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0604438e-82eb-11e6-ac32-baec7272e731.
2016-09-25T06:41:01.140844Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-09-25T06:41:01.144552Z 1 [Note] A temporary password is generated for root@localhost: VhQr7aha4h.X

启动mysql,

➜  support-files ./mysql.server start
Starting MySQL
. SUCCESS!

更改临时密码,

➜  mysql bin/mysqladmin -u root -p password 034039
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

测试重启,

➜  support-files ./mysql.server restart
Shutting down MySQL
. SUCCESS!
Starting MySQL
. SUCCESS!

测试关闭

➜  support-files ./mysql.server stop
Shutting down MySQL
. SUCCESS!

测试登录

➜  ~ mysql -u root -p034039
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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>

查看mysql编码,

mysql> show variables like '%char%' ;
+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | utf8                             |
| character_set_connection | utf8                             |
| character_set_database   | latin1                           |
| character_set_filesystem | binary                           |
| character_set_results    | utf8                             |
| character_set_server     | latin1                           |
| character_set_system     | utf8                             |
| character_sets_dir       | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.01 sec)

修改mysql编码 macOS上安装 MySQL 默认是没有 my.cnf 配置文件的,MySQL 使用默认配置运行。如果需要对 MySQL 进行定制,复制「/usr/local/mysql/support-files/」目录下的一个 cnf 文件到「/etc/」目录下并重命名为 my.cnf,添加如下配置,

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8

重启mysql,查看编码方式,

mysql> show variables like '%char%' ;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    2
Current database: *** NONE ***

+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | utf8                             |
| character_set_connection | utf8                             |
| character_set_database   | utf8                             |
| character_set_filesystem | binary                           |
| character_set_results    | utf8                             |
| character_set_server     | utf8                             |
| character_set_system     | utf8                             |
| character_sets_dir       | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.01 sec)

mysql>

======END======

转载于:https://my.oschina.net/xinxingegeya/blog/751154

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值