1、安装
Mac 启动: 系统偏好设置——>MySQL——> Start MySQL Server
如无法检测mysql,请添加环境变量。参考:https://www.cnblogs.com/developer-qin/p/14505271.html
export PATH=$PATH:/usr/local/mysql/bin
2、验证安装
mysqladmin --version
3、启动
mysql -h 主机名 -u 用户名 -p
mysql -u root -p #启动
mysql> SHOW VARIABLES WHERE Variable_name = 'port'; #显示port
mysql> SHOW VARIABLES WHERE Variable_name = 'hostname';
mysql>select user();
4、
CREATE DATABASE 数据库名;
drop database <数据库名>;
SHOW DATABASES;
use mysql; // 切换数据库
show tables;
update `deployments` set `deployment_key`='xxx' where `id`=5
-------------------------------------------------------------
报错1:
Client does not support authentication protocol requested by server; consider upgrading MySQL client
原因: MySQL8.0版本的加密方式和MySQL5.0的不一样,连接会报错。
解决方法: 如下:启动mysql之后,操作。
- 更改加密方式(原样拷贝到命令窗中)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
- 更改密码:该例子中 123456为新密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
- 刷新:
mysql> FLUSH PRIVILEGES;