LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-11-2012, 04:42 AM   #1
zak100
Member
 
Registered: Jul 2009
Posts: 225

Rep: Reputation: 2
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.
 
Old 09-11-2012, 04:58 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
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.

Last edited by pan64; 09-11-2012 at 06:53 AM. Reason: highlight text
 
Old 09-11-2012, 06:50 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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.
 
Old 09-11-2012, 07:22 AM   #4
rahulkya
Member
 
Registered: Feb 2009
Location: New Delhi
Distribution: Linux mint,Ubuntu,Debian,RHEL 5,slackware 13.1, free BSD,solaris.
Posts: 186
Blog Entries: 3

Rep: Reputation: 33
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
 
Old 09-11-2012, 07:27 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to execute example.sh files like other commands? ssvirdi Linux - Newbie 3 06-23-2010 02:31 PM
Execute kerberos commands in C# tritonbash Linux - Server 0 05-07-2008 05:43 PM
Execute different commands at startup lucazorzi Linux - General 7 11-02-2007 08:46 AM
C -how do i execute linux commands? ocularbob Programming 7 02-29-2004 02:51 PM
how to execute commands on login k4zau Linux - Software 3 10-12-2003 02:52 PM


All times are GMT -5. The time now is 12:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration