LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Not able to execute mysql commands (https://www.linuxquestions.org/questions/linux-newbie-8/not-able-to-execute-mysql-commands-4175426660/)

zak100 09-11-2012 03:42 AM

Not able to execute mysql commands
 
Hi,
I am not able to execute any of the mysql commands. Kindly guide me.


Code:

[root@HP-UX646UU guest]# service mysqld start
Starting MySQL:                                            [  OK  ]
[root@HP-UX646UU guest]# create database db_name
bash: create: command not found
[root@HP-UX646UU guest]# CREATE DATABASE perltest;
bash: CREATE: command not found
[root@HP-UX646UU guest]# /usr/bin/mysql "create database db_name"
ERROR 1049 (42000): Unknown database 'create database db_name'
[root@HP-UX646UU guest]#

Zulfi.

pan64 09-11-2012 03:58 AM

you would need to read the usage of mysql.
The command mysql expects a database name, "create database db_name" is an unknown name. Also see this page about executing sql commands.

chrism01 09-11-2012 05:50 AM

Try reading this https://dev.mysql.com/tech-resources...sql_intro.html
Note that the 'DBA' user in mysql is called 'root' BUT this is nothing to do with the Linux root user; its just an unfortunate (imho) re-use of a well known username.

rahulkya 09-11-2012 06:22 AM

First you have to login into the mysql then only you can give the command to create database or else..below is the command

mysql --user=mysqluser --password=mysqlpasswd --database=mysql
Please note mysql is the default db name in which you login.
then you will be in mysql shell like below
mysql>
mysql> create database db_name;
Query OK, 1 row affected (0.00 sec)


then you can logout from mysql and login into newly created database

mysql --user=mysqluser --password=mysqlpasswd --database=db_name

chrism01 09-11-2012 06:27 AM

I'd recommend NOT putting the passwd section on the cmd line, as that would be visible to other users via top or ps.
If you skip the passwd bit, the DB will prompt you to enter it and it will be invisible (similar to a Linux login)


All times are GMT -5. The time now is 05:41 AM.