mysql 笔记1,登录

mysql退出命令:\c,强制退出:control+c


bash: mysql: command not found

原因:因为mysql命令的路径在/usr/local/mysql/bin下面,所以直接用mysql命令时,

系统在/usr/bin下面查此命令,所以找不到了。

解决办法:ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

提示无权限,加sudo。

但是在mac os x ei capitan 系统中加sudo还是提示无权限,

原因:ei capitan中加入了Rootless机制,不再能够随心所欲的读写很多路径下了。设置 root 权限也不行。

解决办法:增加mysql别名

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

同样,也可以给mysqladmin增加一样的别名

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


进入mysql命令行模式

mysql -u root -p

如果看到下面的提示表示已经登录成功。

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

Your MySQL connection id is 346

Server version: 5.7.11 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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 账户密码,修改的是当前登录的帐户密码

SET PASSWORD = PASSWORD('your new password');

ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

flush privileges;

你可能感兴趣的:(mysql 笔记1,登录)