当前位置: 移动技术网 > IT编程>数据库>Mysql > macos 10.15 安装 MySQL

macos 10.15 安装 MySQL

2020年07月29日  | 移动技术网IT编程  | 我要评论

MySQL在mac系统安装如下

一.下载

https://downloads.mysql.com/archives/community/
如果下载速度过慢 可以使用百度云
mysql-5.7.28-macos10.14-x86_64.dmg
链接: https://pan.baidu.com/s/1CC8sqEe3oC8Shv3EwTYSMQ 密码: 1sjj

二.安装

下载dmg版本 根据步骤如下安装
在进行下一步 下一步的操作之后,通知中心会弹出MySQL的默认密码,记得记录在这里插入图片描述

三.打开数据库服务

在系统设置一栏最下方
有着MySQL图标 点开之后开启MySQL服务
在这里插入图片描述

四.修改默认密码

此处进入mysql 应使用,输入通知栏中的密码即可登录但是:

mysql -u root  -p

但是一直报错

Last login: Sun Jul 26 21:44:42 on ttys000
zhangyu@localhost ~ % mysql -u root -p
zsh: command not found: mysql

只能更改配置文件:

vim ~/.bashrc

添加到文件中

alias mysql=/usr/local/mysql/bin/mysql

输入:wq 保存退出。

配置生效

source ~/.bashrc

执行下面命令

vim ~/.bash_profile

添加

source ~/.bashrc

输入:wq 保存退出。
配置生效

source ~/.bash_profile

登录如下 :source ~/.bash_profile 进入;mysql -u root -p进入;输入密码;登录成功

Last login: Mon Jul 27 11:08:36 on ttys000
zhangyu@localhost ~ % source ~/.bash_profile
(base) zhangyu@localhost ~ % mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 222882
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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> grant all privileges on *.* to 'root'@'192.30.1.%' identified by 'joseph';
Query OK, 0 rows affected, 1 warning (0.00 sec)

[mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

grant all privileges on . to root@“xxx.xxx.xxx.xxx” identified by “密码”;

第一个是所有权限;后面是给哪一个IP权限;
这相当于是给IP-xxx.xxx.xxx.xxx赋予了所有的权限,包括远程访问权限。

然后再输入:flush privileges;

这相当于是重新加载一下mysql权限。

第二种方法:

mysql -u root -p

mysql>use mysql;

mysql>select 'host' from user where user='root';

mysql>update user set host = '%' where user ='root';

mysql>flush privileges;

本文地址:https://blog.csdn.net/ustcmse_coder/article/details/107606821

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网