mac安装mysql5.7.29
2020-07-09 本文已影响0人
沉默羔羊121
下载
https://downloads.mysql.com/archives/community/
选择版本 5.7.29
macOS

下载到本地打开后

双击上图中的文件,开始安装
中途就弹出,初始密码的弹框,记的复制下来。

最后成功如下

安装完后后,command+空格,打开终端
输入
cd ~
vim ./.bash_profile
点击 i进行进行插入操作,在文件中添加下面
export PATH=$PATH:/usr/local/mysql/bin
export PATH=$PATH:/usr/local/mysql/support-files
添加好后点击esc,输入
:wq
保存退出
输入下面命令使其生效
source ~/.bash_profile
然后输入
sudo mysql.server start
启动
启动成功。
mysql -u root -p回车,输入密码进入mysql,
bogon:~ macbook$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)
mysql>
修改密码
set password = password('123456');
show variables like '%char%';
重启服务:mysql.server restart 或 service mysqld restart
localhost:~ macbook$ sudo mysql.server restart
Password:
Shutting down MySQL
.... SUCCESS!
Starting MySQL
. SUCCESS!
localhost:~ macbook$