记录一下Mysql使用时候遇到的问题
前言
作为一名开发,基本都会使用到mysql数据库,那么难以避免的就会遇到这种或者那种的问题,但是随着时间的推移,这些遇到问题的解决办法也许会忘记,所以个人在这里记录并分享一下。
mysql命令未找到
问题:在linux服务器上有一个mysql数据库,我要把mysql数据库的一个库全部备份。于是要到这台服务器的账号密码,进行第一次的登陆。登陆后使用mysql命令进行连接mysql数据库:
[root@localhost ~]# mysql -uxxxx -pxxxx
-bash: mysql: command not found
我天,这是什么鬼,不是有mysql数据库么?
于是进行查看:
[root@localhost ~]# ps -axuf |grep mysql
经过出现的结果,可以看到mysql数据库有,并且已经启动,而且还找到了mysql的路径(此处拷贝一下后面会用到)。
继续查看:
[root@localhost bin]# cd /usr/bin
[root@localhost bin]# ll |grep mysql
没有找到mysql的命令,下面就简单了,把上面复制的内容,软连接到这个目录下就行了:
[root@localhost bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin
上面这个是你本地mysql的地址,如果不是这个地址,请更改成自己的地址即可。
经过上述一些列的操作:
[root@localhost bin]# mysql -uxxxx -pxxxx
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.7.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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>
搞定!!!
ps:linux机制是这些命令行,系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,就会找不到命令,我们只需要映射一个链接到/usr/bin目录下即可。该解决问题的方法同样适用于其他找不到命令的操作。