Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie MySQL question 2

Status
Not open for further replies.

wreikun

Technical User
Apr 23, 2002
63
US
Hello all. I'm brand new to mysql and have just installed mysql to my linux box. After installing, i was able to start it up using the command '/usr/local/mysql/bin/safe_sysqld --usr=mysql &'. Now, however, I'm not able to start it up. Whenever I enter the above command, I get the following message:

Starting mysqld daemon with databases from /var/lib/mysql
020610 13:10:36 mysqld ended
[1]+ Done safe_mysqld --usr=mysql

And when I run ps -ax, it shows that mysql isnt running. Can anybody help? Also, can anyone recommend me a good mysql tutorial site? Thanks in advance.

--REI
 
I am not in my linux box right now so forgive me if I give you wrong or inadequate advice. I had this problem also I believe the solution was to edit the /etc/my.cnf there will be a path there /var/lib/mysql change it to /usr/local/mysql. When I get back on my linux box I will check and repost. Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
Hello. Heres another problem that Ive been running into. whenever I try to start up mysql by entering this command:

shell> mysql -h host -u user -p
Enter password: ********

I get the following output:

ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

What does this mean? I looked for the mysql.sock file but none exists. What is this mysql.sock file? And what do I have to do to make get mysql to start working?

--REI

 
hi

when the mysql server is not running you can't get a connection to it

mysql.sock is a file for communicating with mysql server through sockets on the local machine

first check your error log - according to the location of your sock file i suppose you installed mysql from an rpm so look in the /var/lib/mysql dir for file <hostname>.err, where hostname is the name of your machine ;-) - and look there for the purpose of not starting mysql
 
What version of mysql are you trying to run? Also What flavor and version of linux are you using?

You get that error because your Mysql Daemon is not running. I know that that the Documentation says to use safe_mysqld which I will assume is correct for your version since you did not get a No File blah blah blah error. did you install this from a .rpm file or a .tar?

Try a couple of things first you need to find your directory for your mysql.sock. If you have not updated you system db you should do that first. It may take a few minutes but will help in the long run. to do that just type at the prompt, as the root user

shell>updatedb

Next do a locate to find your files

shell>locate mysql.sock

After that file is found remeber the location or just write it down.

next find the my.cnf file. Should be in the /etc/ directory but who knows for sure.

shell> locate my.cnf

open the my.cnf file in your favorite editor at the beginning of the file there will be some variables that are set. One being 'sock = /directory-some-where/' make sure it matches the same directory that the mysql.sock file was located in. next make sure the port is set right
'port = 3306'

I will assume when you do all of this you will probally find it should not need any changes but it may.

as root user try starting the mysql daemon again, first though switch to directory '/usr/local/mysql' then type the command './bin/mysqld_safe --user=mysql &' note in version 4.0.x to start the daemon it is mysqld_safe and not safe_mysqld. you may want to check your directory to see which one you are using.

well this is about as much as I can say for now, let me know what happens and we can go from there.

HTH Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
An old favourite on new mysql installs is this:
/var/lib/mysql/mysql.sock'
the directory named mysql does not have sufficient privileges for you to access mysql.

chmod 777 /var/lib/mysql

This should allow you to connect.

Hope this helps.

//karv ***************************************
Party on, dudes!
[cannon]
 
I have also been having all of the same problems. I have reinstalled several times... I have done tried everthing listed above. I haven't even been able to set any passwords yet. So far, MySQL has proven to be nothing but a headache.
 
Hello again. Im trying to run MySQL-3.23.49a-pc-linux-gnu-i686 on TurboLinux 6.5 running Apache 1.3.24. I installed MySQL from a .tar file. I followed step by step instuctions in the INSTALL file that came with it when I unpacked the tarball.

I tried to run the commands 'updatedb', 'locate mysql.sock', and locate 'mycnf', however got the following message:

updatedb: this is not a valid slocate database; /var/lib/slocate/slocate.db

and

locate: this is not a valid slocate database /var/lib/slocate/slocate.db

In trying to search for where mysql.sock and my.cnf is located, I tried running 'find' but neither seem to exist on my machine. Also, I found a file named /usr/local/mysql/data/ and this file had the following lines:

TCP port: 3306
Unix socket: /tmp/mysql.sock

However, when I go to the directory /tmp to look for mysql.sock, its not there.

Also, I tried entering the following command in the /usr/local/mysql directory:

./bin/mysql_safe --user=mysql &

however I get an error back saying that ./bin/mysql_safe doesnt exist. I looked in the ./bin directory and the only one thats there that resembles the file 'mysql_safe' is the file called 'safe_mysqld' (which is what ive used when attempting to start up).

Since I dont seem to have a mysql.sock file, would this mean that I somehow didnt install mysql correctly? If thats the case, I wouldnt know where I went wrong since I followed the instructions in the INSTALL file to the tee.

Thanks in advance for the help!!

--REI
 
ok, mysql.sock has mysteriously been found. however, when i enter the following command:

mysqladmin -u root create mydb

I get the following message:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

I checked if mysql.sock exists, and it does. however, the file is empty. My question is: what does this 'mysql.sock' do? and what is this file supposed to consist of for mysql to successfully connect to my server?

Any help is GREATLY appreciated!!

--REI
 
hi

as i wrote in my previous post - the purpose of sock files is to make an &quot;interface&quot; between client apps and the server on the local machine (it's like ports when communicating remotely) - when you run &quot;mysql -u user -ppasswd&quot;, the client app connects to the mysql daemon through the mysql.sock file

the mysql.sock should be of zero length - just think it's something like a pipe ;-)

while trying to start mysql - use the /etc/init.d/mysql (or /etc/rc.d/init.d/mysql, simply look for init.d dir and there for mysql) script - this is the startup script for mysql daemon

when i start my mysql i have the following lines in my log:
020531 14:54:02 mysqld started
/usr/local/mysql/bin/mysqld: ready for connections

btw, this mysql.sock file you found could be some kind of rest from the previous unclean shutdown of mysql - check the date of this file if it corresponds the date and time of mysql server startup

you are not writing if you installed the binaries or from sources - if from sources, try the binaries first - the installation is very easy, as i remember it requires only unpacking the downloaded tarball and changing some paths in the startup scripts

also check out the thread &quot;I am trying to install mySQL on my&quot; by frozenpas

hope that helps
 
wreikun, if you list the /var/lib/ directory what permissions are set on the mysql directory?

Does it look like
drwx------ (other stuff ) mysql

it should look like
drwxrwxrwx (other stuff ) mysql

if the permissions are wrong it will stop you from connecting. ***************************************
Party on, dudes!
[cannon]
 
I appreciate all the help. =) I took a look at the thread 'I am trying to install MySQL' and have followed the instructions listed there. I checked /usr/local/mysql/bin/safe_mysqld script for the 'MYSQL_UNIX_PORT' line, and it was there set to /tmp/mysql.sock, just as how u wrote it. Then, since there was no my.cnf file on my machine, i created it and put that in the /etc directory. And as KarveR suggested, I set all /var/lib/mysql directory and everything under that to permission 777. then I entered the command:

/usr/local/mysql/bin/safe_mysqld &

and mysql seems to have started successfully thanks to all of your help. However, I have a few questions regarding a few things id like to get an understanding of.

first off, before mysql is started, there is no mysql.sock file in the /tmp file. yet there is one in /var/lib/mysql. then, when i start mysql, the mysql.sock mysteriously appears in the /tmp directory. why is this?

second, whats the difference between starting mysql through '/etc/rc.d/init.d/mysql start', and '/usr/local/mysql/bin/safe_mysqld &'? The former command spits out the message:

'Starting mysqld daemon with databases from /var/lib/mysql
mysqld ended'

It doesnt seem to start this way. Yet, the latter command seems to start up mysql just fine. Are these two of the same commands? and why does one start while the other doesnt?

and lastly, what does the my.cnf file do? was this file supposed to be automatically created when i installed mysql?

thanks everybody!

--REI
 
hi
i'm glad to hear your prob has been solved
so now to your questions:

the mysql.sock file is created during the daemon start and destroyed when stopping it - there is no need of it when the server is not running

as i wrote i suppose that one located in /var/lib/mysql is a rest of some unclean shutdown of mysql

and bacause the server is set (in /usr/local/mysql/bin/safe_mysqld) to create its sock file in /tmp dir it's not mysterious when it appears there ;-)

that /etc/init.d/mysql script does some wider prep before starting the server - setting datadir, pidfile location dir, ...

so those two are not the same scripts - probably there are some path probs in the startup script - check it, otherways the server will not start on the next boot (if you did not put the working command in the rc script)

the /etc/my.cnf file is for global mysql settings - e.g. the client apps are looking there where they should look for that sock file, etc.
for details look in the mysql documentation, chapter 4.1 configuring mysql

i don't know if it's supposed to be created during install, i think no, i had to create it myself, but only once, my first rpm install of mysql did not created it

and to that permissions i have 755 and works fine ;-)
 
hello again. i have a few more questions about the basics of mysql. whats the difference between starting the mysql server using this command:

bin/safe_mysqld &

as opposed to:

bin/safe_mysqld --user=mysql &

why does mysql require there to be a user and group by the name of 'mysql'? and when starting up mysql, do i have to start it using the user 'mysql'? or can i set --user equal to another username?

what are the main configuration files to mysql that hold all the settings and paths for mysql?

thanks!

--REI
 
Depending on how you start the server will grant or deny the server root privileges, started as user=mysql will not allow mysql root's write and delete privileges (a good thing)
Started as root, is a securtiy hazard waiting to happen.

you can start mysql under any name, but the specifics of file permissions are why you have a mysql group and user.

The mysql user should in no circumstances have root equivalence and the mysqlgroup should be limited in what files it is allowed to access and ideally be limited to its home directory. (Disallowing any read or write to files outside of the mysql default directories other than the system /tmp dir).

System secrurity is a big topic of which I am no expert.
I only know at best how to minimise risk.

For best results on the pro's and con's of user/group secrurity and priviledges post on the general unix forum.

(If you don't have a few weeks to spare tho, just start mysql with --user=mysql )[lol] ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top