#mysql:command not found

一、问题描述

  1、在linux中已经安装好mysql,通过#ps -ef |grep mysql 能显示mysql已经启动,但去进入mysql命令页面出现如下问题:

1   [[email protected] ~]# mysql u -p
2 -bash: mysql: command not found

  查找mysql是否已经启动

1 [[email protected] ~]# ps -ef  | grep mysql
2 root      1172     1  0 18:28 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/service/mysql --pid-file=/service/mysql/root.pid
3 mysql     1285  1172  9 18:28 ?        00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/service/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/service/mysql/root.err --pid-file=/service/mysql/root.pid
4 root      1440  1288  0 18:28 pts/1    00:00:00 grep mysql

  2、查找问题产生原因:

  原因:这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令,我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件。

首先得知道mysql命令或mysqladmin命令的完整路径,比如mysql的路径是:/usr/local/mysql/bin/mysql,【此路经是mysql实际安装路径】我们则可以这样执行命令  

1 [[email protected] bin]# ln -fs /usr/local/mysql/bin/mysql /usr/bin/

  3、连接mysql  

 1 [[email protected] bin]# mysql -u -p
 2 Welcome to the MySQL monitor.  Commands end with ; or \g.
 3 Your MySQL connection id is 1
 4 Server version: 5.6.20 Source distribution
 5
 6 Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
 7
 8 Oracle is a registered trademark of Oracle Corporation and/or its
 9 affiliates. Other names may be trademarks of their respective
10 owners.
11
12 Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
13
14 mysql> Ctrl-C -- exit!
15 Aborted
时间: 2025-01-10 12:18:51

#mysql:command not found的相关文章

Linux 下 -bash: mysql: command not found解决办法

-bash: mysql: command not found 1.vim ~/.bash_profile 最下面写 export PATH=$PATH:/usr/local/mysql/bin(你的安装bin目录) :wq 保存退出 2.source ~/.bash_profile 然后就直接可以实现了 给分吧 亲自试验过 3. >>mysql  -uroot -p >>输入密码

解决bash: mysql: command not found 的方法

[email protected] ~]# mysql -u root-bash: mysql: command not found 原因:这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令,我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件.首先得知道mysql命令或mysqladmin命令的完整路径,比如mysql的路径是:/usr/local/mysql/bin/mysql,我们则可以这样执行命令: # ln -s /us

解决linux mysql命令 bash: mysql: command not found 的方法

错误: [email protected] ~]# mysql -u root-bash: mysql: command not found 原因:这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令,我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件.首先得知道mysql命令或mysqladmin命令的完整路径,比如mysql的路径是:/usr/local/mysql/bin/mysql,我们则可以这样执行命令: # ln -s

/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh: line 19: mysql: command not found

[[email protected] ~]# tail -f /tmp/zabbix_agentd.log /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh: line 19: mysql: command not foundvi /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh: line RES=`/usr/local/mysql/bin/mysql -ur

MySQL问题解决:-bash:mysql:command not found

问题: [[email protected] /]# mysql -uroot -p -bash: mysql: command not found www.2cto.com 因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,系统在/usr/bin下面查此命令,所以找不到了 解决办法是: ln -s /usr/local/mysql/bin/mysql /usr/bin 做个链接即可

MySql command line client 命令系列

—————————————————————————————————————————————————————————— 一.启动与退出 1.进入MySQL:启动MySQL Command Line Client(MySQL的DOS界面),直接输入安装时的密码即可.此时的提示符是:mysql> 2.退出MySQL:quit 或 exit 二.库操作 1.创建数据库 命令:create database 例如:建立一个名为xhkdb的数据库 mysql> create database xhkdb;

安装 MySQL报错 -bash: mysql: command not found

安装MySQL后(安装文件),不能直接在命令行中mysql. 因为命令行直接查找的是/usr/local/bin下边的命令,需要我们把mysql的命令放到.bash_profile中. vim ~/.bash_profile 添加:export PATH=$PATH:/usr/local/mysql/bin 保存,退出 重新启动(加载)bash_profile文件 source ~/.bash_profile 就可以了. # mysql -u root-bash: mysql: command

Mac os安装MySQL数据库,系统提示mysql: command not found该怎么办

当我们安装好MySQL后,在终端输入mysql命令,发现并不能看到自己安装的数据库,这是因为你没有配置环境变量. 在os系统中安装MySQL数据库默认保存在/usr/local/mysql 那么我们应该如何配置环境变量呢? 1.打开terminal,输入:sudo su   回车  进入系统管理员管理目录(当然你要输入你的用户密码才能进入) 2.输入命令:vim /etc/profile   接着就进入到vim编辑界面 3.在vim编辑界面,按i进入编辑状态,接着,就可以增加路径名称,输入命令:

Linux环境下mysql报错:bash: mysql: command not found 的解决方法

# mysql -u root-bash: mysql: command not found 原因:这是由于系统默认会查找/usr/bin下的命令. 如果这个命令不在这个目录下,当然会找不到命令. 我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件. # ln -s /usr/local/mysql/bin/mysql /usr/bin 原文地址:https://www.cnblogs.com/ming-4/p/11690947.html