Web Hosting Talk







View Full Version : Why is mysql an unknown command in SSH?


JTM
07-15-2002, 11:13 AM
I just installed the latest versions of Apache, PHP, and MySQL on my dedicated server running Red Hat 7.2. For some reason when I enter mysql or mysql_config it comes up with: bash: mysql: command not found

I am using Webmin to adminster my databases and everything is workign fine, except through the command line. Can somebody tell me what I need to do to get my server to recognize these commands? I checked the usr/bin directory and they aren't there. The only place I found them in was in: /usr/local/mysql/bin

I am trying to install DBI::mysql but I'm getting the following errors:

[root@userid DBD-mysql-2.1017]# mysql_config
bash: mysql_config: command not found

[root@userid DBD-mysql-2.1017]# perl Makefile.PL
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 169.
readline() on closed filehandle PIPE at Makefile.PL line 171.
I will use the following settings for compiling and testing:

cflags (mysql_config) = /usr/local/mysql
libs (mysql_config) = /usr/local/mysql
nocatchstderr (mysql_config) = /usr/local/mysql
ssl (mysql_config) = /usr/local/mysql
testdb (mysql_config) = /usr/local/mysql
testhost (mysql_config) = /usr/local/mysql
testpassword (mysql_config) = /usr/local/mysql
testuser (mysql_config) = /usr/local/mysql

To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.

Unrecognized argument in LIBS ignored: '/usr/local/mysql'
Using DBI 1.28 installed in /usr/local/lib/perl5/site_perl/5.6.1/i686-linux/auto/DBI
Writing Makefile for DBD::mysql
[root@userid DBD-mysql-2.1017]# make
cc -c -I/usr/local/lib/perl5/site_perl/5.6.1/i686-linux/auto/DBI /usr/local/mysql -DDBD_MYSQL_WITH_SSL -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"2.1017\" -DXS_VERSION=\"2.1017\" -fpic -I/usr/local/lib/perl5/5.6.1/i686-linux/CORE dbdimp.c
In file included from dbdimp.c:29:
dbdimp.h:31:49: mysql.h: No such file or directory
dbdimp.h:32:49: errmsg.h: No such file or directory
make: *** [dbdimp.o] Error 1

[root@userid DBD-mysql-2.1017]# mysql_config
bash: mysql_config: command not found

[root@userid DBD-mysql-2.1017]# mysql
bash: mysql: command not found


Any advice would be greatly appreciated.

JTM

CJCS
07-15-2002, 11:42 AM
Hy,

perhaps you have not installed mysql in a default path ?

Try to make /path/to/mysql/bin/mysql this should work. If you do not know where you have installed mysql try to make find / -name "mysql"

Greetings
Oliver

JTM
07-15-2002, 11:48 AM
I posted my question in another forum and this is what somebody wrote back:


Thats because you've installed MySQL in a non-standard location, and without adding that to your PATH, your OS can't find it. You'll also have to type /usr/local/mysql/bin/mysql each time you want to run the MySQL client. That's what the PREFIX= is for when compiling/installing packages. Also, type man 7 hier in your shell to get some info about where to install things and FHS in general.

Best thing now would be to remove mysql (and Apache and PHP if configured similar), and install them with PREFIX=/usr/local. That way all of your other software won't have problems finding them, and similar dependencies won't break other installs.

I'm not familiar with DBI::mysql, but I reckon that it's possible to supply another path to MySQL somehow. But instead of having to do this for every software you install that depends on MySQL, it's easier to install it in a place where it should be.

I followed these instructions and now I'm a little confused. After removing the old MySQL installation and installing it again with PREFIX=/usr/local, the mysql commands work from the command line.

For my last install, I followed the tutorial at this site: http://www.wowwebdesigns.com/power_guides/killer_trio_part_3.php#s3.3

I had entered PREFIX=/usr/local/mysql before and ran the scripts/install_mysql_db and it worked fine. But this time it wasn't finding the mysqld. It was looking for it i '/usr/local/mysql/libexec/mysqld' instead of 'Didn't find /usr/local/libexec/mysqld'. I though I should have a mysql directory under /usr/local? The only way I ended up getting the script to run was by removing mysql from the original path in the script which was /usr/local/mysql.

Then when I got to the step where it says:

chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql

I started to think something was wrong since I'd have to chown and chgrp for the entire local directory. Is this correct?


John

apollo
07-15-2002, 02:31 PM
you could also make a symbolic link instead of moving it to another dir

man ln


or you could add new mysql binary directory to your PATH variable

JTM
07-15-2002, 02:36 PM
I'm a little confused about what I should do. Which one is correct when compiling MySQL?

PREFIX=/usr/local/mysql
PREFIX=/usr/local

If I install it into /usr/local/mysql will the server recognize the mysql commands in SSH? It didn't when I installed it there last time I did that.

Also, I did this chown -R mysql /usr/local/ to my /usr/local directory. Is that bad? Do I need to change it? If so, to what?


JTM