LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-23-2012, 03:43 AM   #1
zak100
Member
 
Registered: Jul 2009
Posts: 225

Rep: Reputation: 2
Executing mysql


Hi,
I have checked mysql on my system using:
Code:
whereis msysql
I got
Code:
  mysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1mysql.1.gz
Kindly guide me how to execute mysql.

Zulfi.
 
Old 07-23-2012, 03:44 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
you run "mysql"

see "man mysql" for full details of using the mysql command.
 
Old 07-23-2012, 04:24 AM   #3
vitalstrike82
Member
 
Registered: Oct 2007
Location: Singapore
Distribution: OpenSuse, Slackware, Redhat
Posts: 318

Rep: Reputation: 40
From your post, i assume mysql is already installed in your machine.
Execute these commands

Start the server

# usr/local/mysql/bin/mysqld_safe --user=mysql &


Check if server is starting
# /usr/local/mysql/bin/mysqladmin ping

If responds on the terminal tat sqld is alive, you have successful start the server.
 
Old 07-23-2012, 04:32 AM   #4
piyush.sharma
Member
 
Registered: Jul 2012
Location: Delhi, India
Distribution: CentOS
Posts: 82

Rep: Reputation: Disabled
To start with mysql you may need to set root password or create new user.
http://www.ntchosting.com/mysql/create-user.html
This link will help you to do the stuff
 
Old 07-25-2012, 12:53 AM   #5
zak100
Member
 
Registered: Jul 2009
Posts: 225

Original Poster
Rep: Reputation: 2
Hi,
I tried to execute mysql using

Code:
/usr/bin/mysql
ERROR 2002 (HY000): Can't connect to local MYSQL server through socket '/var/lib/mysql/mysql.sock (2)
However following command worked but it didnt recognize the user:

Code:
$ sudo /etc/init.d/mysql
password for guest:
guest is not in the sudoers file. This incident will be reported.
Kindly guide me how to create a user.

I checked the link provided above but i didnt find the command for creating user.

I also tried:

Code:
$mysqladmin
mysqladmin Ver 8.41 Distrib 5.0.67, for redhat-linux -gnu on i386
......
....
.....
Kindly guide me how to execute mysql.

Zulfi.
 
Old 07-25-2012, 01:27 AM   #6
piyush.sharma
Member
 
Registered: Jul 2012
Location: Delhi, India
Distribution: CentOS
Posts: 82

Rep: Reputation: Disabled
Command to set root password :
/usr/bin/mysqladmin -u root password 'root_password'

Create a database :
/usr/bin/mysql -u root -p'root_password' -e "create database db_name"

Create new user :
/usr/bin/mysql -u root -p'root_password' -e "CREATE USER 'user_name'@'127.0.0.1' IDENTIFIED by 'user_password';"

Grant privileges :
/usr/bin/mysql -u root -p'root_password' -e "grant all privileges on 'db_name'.* to 'user_name'@'127.0.0.1' identified by 'user_password'"

I guess, now you can create a new user and assign privileges on a perticular database.
 
Old 07-25-2012, 01:35 AM   #7
piyush.sharma
Member
 
Registered: Jul 2012
Location: Delhi, India
Distribution: CentOS
Posts: 82

Rep: Reputation: Disabled
before executing these command please ensure that mysql is running

service mysql status

if it is stopped, start it with
service mysql start
 
Old 07-25-2012, 02:55 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Hmm... he appears to be using an account called "guest"... doesn't bode well for getting root access to me...
 
Old 07-25-2012, 03:17 AM   #9
zak100
Member
 
Registered: Jul 2009
Posts: 225

Original Poster
Rep: Reputation: 2
Hi,

Thanks for your reply.

I tried:
Code:
guest@HP-UX645PA ~]$ service mysql start
mysql: unrecognized service
Then:
Code:
[guest@HP-UX645PA ~]$ /usr/bin/mysqladmin -u root password
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
Then:
Code:
[guest@HP-UX645PA ~]$ service mysqld start
touch: cannot touch `/var/log/mysqld.log': Permission denied
chown: changing ownership of `/var/log/mysqld.log': Operation not permitted
chmod: changing permissions of `/var/log/mysqld.log': Operation not permitted
chown: changing ownership of `/var/lib/mysql': Operation not permitted
chmod: changing permissions of `/var/lib/mysql': Operation not permitted


Timeout error occurred trying to start MySQL Daemon.
Starting MySQL:                                            [FAILED]
Kindly guide me with problem.

Zulfi.
 
Old 07-25-2012, 03:22 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
mysqld isn't installed I guess. If you're on a redhat clone, try "yum install mysql-server" however as above I'm concerned that you have no root access to this system as you're on a "guest" account.

What do you actually want to do with MySQL in the first place? You expect to use a database running on the local machine, or connect somewhere else? You seem to be just copying and pasting random commands given here to you, so some clarity on your actual goals would help everyone I think.

Last edited by acid_kewpie; 07-25-2012 at 03:32 AM.
 
1 members found this post helpful.
Old 07-25-2012, 03:24 AM   #11
piyush.sharma
Member
 
Registered: Jul 2012
Location: Delhi, India
Distribution: CentOS
Posts: 82

Rep: Reputation: Disabled
Sorry it was mistaken the work

try :
service mysqld status
if it is stopped then
service mysqld start
 
Old 07-25-2012, 03:48 AM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
The program "mysql" is the client you use to connect to a mysql server. The program "mysqld" is the server program. It runs as a service, and you should have the service start when you boot.

You should download the mysql reference manual for your mysql version (run "/usr/sbin/mysqld --version" to find out your version) It has instructions on creating users, and importantly, what you need to do after installing mysql to secure it.
http://dev.mysql.com/doc/

You need to create a password for the root mysql user. Dropping the default demo database is also advisable. See section 2.10.2: "Securing the Initial MySQL Accounts"
 
Old 07-25-2012, 09:20 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
As ref post#10, please tell us what distro+version you have, as this will make a difference to the cmds you require.
Code:
uname -a

cat /etc/*release*
 
Old 07-30-2012, 02:31 AM   #14
zak100
Member
 
Registered: Jul 2009
Posts: 225

Original Poster
Rep: Reputation: 2
Hi,
I tried the cat command and I got following output:

Code:
[guest@HP-UX645PA ~]$ cat /etc/*release*
Fedora release 10 (Cambridge)
cat: /etc/lsb-release.d: Is a directory
Fedora release 10 (Cambridge)
Fedora release 10 (Cambridge)
cpe://o:fedora_project:fedora:10
[guest@HP-UX645PA ~]$
Kindly guide me.
Zulfi.
 
Old 07-30-2012, 02:33 AM   #15
zak100
Member
 
Registered: Jul 2009
Posts: 225

Original Poster
Rep: Reputation: 2
Hi,
I also tried:

Code:
[guest@HP-UX645PA ~]$ uname -a
Linux HP-UX645PA 2.6.27.5-117.fc10.i686 #1 SMP Tue Nov 18 12:19:59 EST 2008 i686 i686 i386 GNU/Linux
[guest@HP-UX645PA ~]$

Zulfi.
 
  


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
MySQL backup cron job not executing correctly lakridserne Linux - Server 3 03-02-2011 10:10 AM
Bash script run via cron not executing MYSQL command mackstar Linux - Server 4 04-23-2009 06:01 AM
Lost connection to MySQL server during query when executing 'REPAIR TABLE ... '? Ujjain Linux - Server 3 03-20-2009 10:05 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 04:35 PM


All times are GMT -5. The time now is 12:35 PM.

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