LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 02:43 AM   #1
zak100
Member
 
Registered: Jul 2009
Posts: 262

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, 02:44 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you run "mysql"

see "man mysql" for full details of using the mysql command.
 
Old 07-23-2012, 03: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, 03: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-24-2012, 11:53 PM   #5
zak100
Member
 
Registered: Jul 2009
Posts: 262

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, 12: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, 12: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, 01:55 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

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, 02:22 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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 02:32 AM.
 
1 members found this post helpful.
Old 07-25-2012, 02: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, 02:48 AM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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, 08:20 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 01:31 AM   #14
zak100
Member
 
Registered: Jul 2009
Posts: 262

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, 01:33 AM   #15
zak100
Member
 
Registered: Jul 2009
Posts: 262

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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:02 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
Open Source Consulting | Domain Registration