我爱编程

MySql 的安装 与connection

2018-03-07  本文已影响149人  过眼云烟1102

1. 下载mysql for mac: https://dev.mysql.com/downloads/mysql/

3. Continue -> Continue, Agree -> Install -> 输入管理员密码

4. 记录下来弹窗中的密码

5. 进入系统偏好设置, 找到mysql, 启动服务

6. 将mysql的命令添加到系统中

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

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

--------------------------------------------------------------------------- 

或者:(1).进入/usr/local/mysql/bin,查看此目录下是否有mysql

(2).执行vim ~/.bash_profile

在该文件中添加mysql/bin的目录

PATH=$PATH:/usr/local/mysql/bin

添加完成后,按esc,然后输入wq保存。

(3).最后在命令行输入source ~/.bash_profile

7. 通过mysql -uroot -p登录mysql, 输入之前保存的密码

8. 重置mysql初始密码

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');  

--------------------------------------------------------------------------- 

mysqladmin -u root -p password newpass

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.

7.   mysql -u root -p  

Enter password:   输入 newpass 自己设置的 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 146

Server version: 5.7.21 MySQL Community Server (GPL)

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

+--------------------+

4 rows in set (0.09 sec)

mysql>

我是在终端 切换到 root 下删除的。切换root。sudo -i

MySQL的卸载一般使用终端的方式操作(安装包中有安装文件,但是没有卸载文件,只能通过终端命令的方式卸载)

sudo rm /usr/local/mysql  

sudo rm -rf /usr/local/mysql*  

sudo rm -rf /Library/StartupItems/MySQLCOM  

sudo rm -rf /Library/PreferencePanes/My*  

vim /etc/hostconfig   

:wq。回车 推出

rm -rf ~/Library/PreferencePanes/My*  

sudo rm -rf /Library/Receipts/mysql*  

sudo rm -rf /Library/Receipts/MySQL*  

sudo rm -rf /var/db/receipts/com.mysql.*  

最后 mysql 图标消失

上一篇下一篇

猜你喜欢

热点阅读