macOS如何使用终端管理MySQL
一,添加环境变量
打开配置文件,~/.bash_profile 添加一下内容。
# 设置MySQL
MYSQL_HOME=/usr/local/mysql
PATH=$PATH:$MYSQL_HOME/bin
.bash_profile是用户级环境变量,https://javascript.net.cn/article?id=496
二,删除MySQL匿名用户
mysql> select host,user from user;
+------------------------+------+
| host | user |
+------------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | |
| localhost | root |
| macdemacbook-air.local | |
| macdemacbook-air.local | root |
+------------------------+------+
6 rows in set (0.00 sec)
mysql> delete from user where user='';
Query OK, 2 rows affected (0.01 sec)
重启MySQL服务或重启电脑。随后即可在终端使用mysql
声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。