Problem: MySQL: -bash: mysql: command not found

本文解决了在CentOS上使用MySQL时,终端中输入mysql命令却提示'command not found'的问题。通过创建软链接到MySQL安装目录下的bin/mysql,可以成功解决此问题。

Problem

Problem: MySQL: -bash: mysql: command not found

On CentOS, MySQL works fine, but can not use “mysql” command in terminal, and says “-bash: mysql: command not found”.


Solution

# cd /usr/local/bin
# ln -fs /MYSQLPATH/bin/mysql mysql

MYSQLPATH is the path to MySQL installed directory.


Reference

https://www.cnblogs.com/jr1260/p/6590860.html

yum install -y net-snmp net-snmp-utils Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package net-snmp.x86_64 1:5.7.2-49.el7_9.4 will be installed --> Processing Dependency: net-snmp-agent-libs = 1:5.7.2-49.el7_9.4 for package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 --> Processing Dependency: perl(Data::Dumper) for package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 --> Processing Dependency: libnetsnmptrapd.so.31()(64bit) for package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 --> Processing Dependency: libnetsnmpmibs.so.31()(64bit) for package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 --> Processing Dependency: libnetsnmpagent.so.31()(64bit) for package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 ---> Package net-snmp-utils.x86_64 1:5.7.2-49.el7_9.4 will be installed --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be installed ---> Package net-snmp-agent-libs.x86_64 1:5.7.2-49.el7_9.4 will be installed ---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed Removing mariadb-libs.x86_64 1:5.5.68-1.el7 - u due to obsoletes from installed mysql-community-libs-5.7.37-1.el7.x86_64 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be installed --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 1:net-snmp-agent-libs-5.7.2-49.el7_9.4.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:net-snmp-agent-libs-5.7.2-49.el7_9.4.x86_64 --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 --> Finished Dependency Resolution Error: Package: 1:net-snmp-agent-libs-5.7.2-49.el7_9.4.x86_64 (updates) Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit) Error: Package: 2:postfix-2.10.1-9.el7.x86_64 (@base) Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit) Error: Package: 1:net-snmp-5.7.2-49.el7_9.4.x86_64 (updates) Requires: libmysqlclient.so.18()(64bit) Error: Package: 1:net-snmp-agent-libs-5.7.2-49.el7_9.4.x86_64 (updates) Requires: libmysqlclient.so.18()(64bit) Error: Package: 2:postfix-2.10.1-9.el7.x86_64 (@base) Requires: libmysqlclient.so.18()(64bit) You could try using --skip-broken to work around the problem ** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows: 2:postfix-2.10.1-9.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit) 2:postfix-2.10.1-9.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit) [root@localhost w123]# net-snmp-create-v3-user -ro -A yu202211 -a SHA temp_user bash: net-snmp-create-v3-user: command not found... [root@localhost w123]#
09-23
bash-4.2# ping www.baidu.com bash: ping: command not found bash-4.2# bash-4.2# bash-4.2# bash-4.2# bash-4.2# bash-4.2# bash-4.2# echo "nameserver 8.8.8.8" >> /etc/resolv.conf bash-4.2# yum update Loaded plugins: ovl https://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: repo.mysql.com; Unknown error" Trying other mirror. One of the configured repositories failed (MySQL Tools Community), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=mysql-tools-community ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable mysql-tools-community or subscription-manager repos --disable=mysql-tools-community 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=mysql-tools-community.skip_if_unavailable=true failure: repodata/repomd.xml from mysql-tools-community: [Errno 256] No more mirrors to try. https://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: repo.mysql.com; Unknown error" bash-4.2# ping www.baidu.com bash: ping: command not found bash-4.2#
最新发布
11-06
[root@VM-16-6-opencloudos ~]# mysqld --install bash: mysqld: command not found [root@VM-16-6-opencloudos ~]# mysqld --initialize --user=mysql --console bash: mysqld: command not found [root@VM-16-6-opencloudos ~]# sudo dnf update Last metadata expiration check: 5:07:13 ago on Sat 25 Oct 2025 01:29:49 AM CST. Dependencies resolved. Nothing to do. Complete! [root@VM-16-6-opencloudos ~]# sudo dnf install mysql-server Last metadata expiration check: 5:07:29 ago on Sat 25 Oct 2025 01:29:49 AM CST. Error: Problem: package mysql-server-8.0.43-2.oc9.x86_64 from AppStream requires mysql, but none of the providers can be installed - cannot install the best candidate for the job - package mysql-8.0.41-2.oc9.x86_64 from AppStream is filtered out by exclude filtering - package mysql-8.0.43-1.oc9.x86_64 from AppStream is filtered out by exclude filtering - package mysql-8.0.43-2.oc9.x86_64 from AppStream is filtered out by exclude filtering (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) [root@VM-16-6-opencloudos ~]# sudo systemctl start mysqld [root@VM-16-6-opencloudos ~]# sudo systemctl enable mysqld mysqld.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable mysqld [root@VM-16-6-opencloudos ~]# dnf clean all dnf makecache 33 files removed BaseOS 9 - x86_64 3.7 MB/s | 1.2 MB 00:00 AppStream 9 - x86_64 27 MB/s | 13 MB 00:00 extras 9 - x86_64 6.2 kB/s | 884 B 00:00 Docker CE Stable - x86_64 263 kB/s | 57 kB 00:00 Extra Packages for OpenCloudOS 9 - EPOL 44 MB/s | 25 MB 00:00 Metadata cache created. [root@VM-16-6-opencloudos ~]# dnf install mysql-server --allowerasing Last metadata expiration check: 0:00:16 ago on Sat 25 Oct 2025 06:39:44 AM CST. Error: Problem: package mysql-server-8.0.43-2.oc9.x86_64 from AppStream requires mysql, but none of the providers can be installed - cannot install the best candidate for the job - package mysql-8.0.41-2.oc9.x86_64 from AppStream is filtered out by exclude filtering - package mysql-8.0.43-1.oc9.x86_64 from AppStream is filtered out by exclude filtering - package mysql-8.0.43-2.oc9.x86_64 from AppStream is filtered out by exclude filtering (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) [root@VM-16-6-opencloudos ~]# systemctl start mysqld [root@VM-16-6-opencloudos ~]# systemctl enable mysqld mysqld.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable mysqld [root@VM-16-6-opencloudos ~]#
10-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值