You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 查看mysqladmin 当前版本
mysqladmin version
// 将会输出类似如下结果
mysqladmin Ver 8.42 Distrib 5.6.27, for osx10.10 on x86_64
Copyright (c) 2000, 2015, 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.
Server version 5.6.27
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 8 min 11 sec
Threads: 1 Questions: 23 Slow queries: 0 Opens: 87 Flush tables: 1 Open tables: 80 Queries per second avg: 0.046
// 将下面的 newpwd 替换成自己的密码
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');
因为此时还存在匿名账号,建议不允许匿名登录,那么可以通过下面命令来移除匿名账号
shell> mysql -u root -p
Enter password: (enter root password here)
mysql> DROP USER ''@'localhost';
mac mysql 安装及初始配置
安装
通过安装包安装
访问官网MySQL Community Server的下载页面,如果对性能或者簇群的特别需要选这个版本就好,不用选择下载MySQL Cluster Community Edition
通过 homebrew 安装
安装完成后,若是Unix系统一般会把常用的命令都软连接到了
/usr/local/bin
里方便在命令行下直接使用初始配置
初始化数据目录
注意:通过二进制文件或者源码编译安装的方式数据目录没有自动初始化配置的,需要手动处理,而通过
dmg
等方式安装的则默认初始化好了数据目录。具体步骤请查看Initializing the Data Directory
启动mysql服务
测试mysql服务器
可通过下面命令来查看当前有哪些数据库
修改初始账号密码
mysql 安装完成后,初始默认有 root 账号及匿名账号并且其密码为空。可通过下面命令查看初始账号密码列表
通过下面命令来重设root账号的密码
因为此时还存在匿名账号,建议不允许匿名登录,那么可以通过下面命令来移除匿名账号
注: 上面命令为官方所介绍,但是在
[email protected] mysql@Ver 14.14 Distrib 5.6.27
下设置后再查看发现 [email protected] 并没有改掉了密码,但是实际已经生效,此外匿名账号也没有删除,后来通过可视化工具直接删除了(下面有介绍)完成这一切后,再次使用root账号登录mysql就需要加入参数
-p
及输入密码了添加管理用户
若要添加额外的管理用户及做好各数据库的权限管理,具体请查看官网Adding User Accounts
可视化工具
首推sequel pro可以方便快捷地通过可视化界面来操作数据库
The text was updated successfully, but these errors were encountered: