[转载]MAC OS X 安装完mysql后终端不识别mysql命令的解决办法

来源:互联网 发布:ug nx11编程新功能 编辑:程序博客网 时间:2024/05/29 11:52

错误现象:

终端显示如下:-bash: mysql: command not found

原因:这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然就找不到命令

解决方法:

我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件。
1. 知道mysql命令或mysqladmin命令的完整路径,比如mysql的路径是:/usr/local/mysql/bin/mysql,

2. 执行命令:$sudo ln -s /usr/local/mysql/bin/mysql /usr/bin


===============================================================

忘记mysql密码可进行如下操作,楼主用的mac os x:

先把mysql服务关掉,然后执行过程如下:

TT-MacBook-Air:~ jasonyao$sudo mysqld_safe --skip-grant-table &
[1] 1182
TT-MacBook-Air:~ jasonyao$ 140402 20:10:58 mysqld_safe Logging to '/usr/local/mysql/data/TT-MacBook-Air.err'.
140402 20:10:58 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.6.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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>update user set password=PASSWORD('new password') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.01 sec)

mysql>



0 0
原创粉丝点击