# MySQL

## fishers4rus

How does one set up mysql?????

I used the instructions provided after a successful ebuild, and cannot get it to accept my passwords/hostname

'Ny suggestions???

----------

## mooman

Have you confirmed that it's actually running?

do:

```
ps -a | grep -i mysql
```

and confirm it's listed.  Then do:

```
netstat -an | grep 3306
```

to see that it's "listening".

If you pass both of those, it *should* be up and ready to use...  Then you probably just have a security issue as far as logging in...

If not, then you probably need to start the service first...

----------

## fishers4rus

Oddly enough, it gives no response to the ps -a | grep -i mysql but i have a response for the netstat -an | grep 3306:

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN

and it wont allow me to attempt a /etc/init.d/mysql start, givs me a 

ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

error

----------

## eric_s

 *fishers4rus wrote:*   

> Oddly enough, it gives no response to the ps -a | grep -i mysql but i have a response for the netstat -an | grep 3306:
> 
> tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN
> 
> and it wont allow me to attempt a /etc/init.d/mysql start, givs me a 
> ...

 

you might want to use ps -ef |grep mysql 

Also,  the last message  (ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)) means that to access mysql as root you need to supply a password:

```

# mysql -u root -p

Enter password:

```

Now, I don't know what is the default install on gentoo, assuming you used an ebuild for mysql, but if I was you, I would just press enter when prompted for password.

----------

## fishers4rus

Well, tried that, and thanks, but to that I get an error of:

mysql -u root -p

Enter password:

ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

but the demon is running

----------

## fishers4rus

Well thought the daemon was running, started it up and get an errror like this:

mysql -u root -p

Enter password:

ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)

Im frustrated  :Evil or Very Mad: 

----------

## rac

If all else fails, you can wipe /var/lib/mysql and run ebuild config on the mysql ebuild again to start afresh.

----------

## fishers4rus

well, I have been, thats the trouble, cant get it running even with multiple installs/uninstalls/installs.  I know its just me, not knowing what I'm doing,  so I'm asking here   :Smile: 

----------

## fishers4rus

Im thinking its something in my hostname, but I'm not sure what exactly.  Some Info about my setup:

Run on a cablemodem 

/ect/hosts: 127.0.0.1       localhost 4fishers94

I get the errors on cant connect to @localhost, but im just too inexperienced to even know where to look for help/manual on this

Tried the mysql homepage, but no dice, unfortunatly

----------

## rac

 *fishers4rus wrote:*   

> well, I have been, thats the trouble, cant get it running even with multiple installs/uninstalls/installs.

 I'm not talking about uninstalling and installing things.  I'm saying something like this: 

```
# rm -rf /var/lib/mysql

# ebuild /var/db/pkg/mysql-version/mysql-version.ebuild config
```

...you have to replace the -version stuff with what is appropriate for your system.  Then make sure the daemon is running, and you should be able to connect with a blank root password.  Unless you're specifying the -h option, your hostname is irrelevant - the mysql client connects with the server via a local FIFO, and does not use the network at all.  Moving this discussion to Networking and Security, BTW, as Newbies is closing.

----------

## WrestleManiac

you should make sure that your /etc/hosts has at least this line in it

```
127.0.0.1 localhost
```

because when you do a mysql_install_db it uses this as a base for hosts in the mysql.user table.  Then you should be able to type:

```
mysqladmin -h localhost -u root password 'YOUR NEW PASS'
```

To change the root password on your machine. Then type:

```
mysql -h localhost -u root -p
```

to actually play around with my mysqld

-good luck

----------

## Ateo

Seems a catch 22 has been found. I've uninstalled/reinstalled and ebuilt mysql and yet I'm prompted with the same error each and every time:

# mysqladmin -u root password DumbPassword

mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

Granted, upon the initial installed on mysql, it worked fine. I even imported my database backup. Then after installing php, it stopped. And hasn't worked since.

Anything new?

----------

## Ateo

I've found this:

If I run # /usr/bin/mysqld_safe mysql starts up.

----------

## slartibartfasz

 *-Amoeba- wrote:*   

> I've found this:
> 
> If I run # /usr/bin/mysqld_safe mysql starts up.

 

hmm - thats the usual way to start mysql...from /etc/ini	t.d/mysql:

```

ebegin "Starting mysqld"

/usr/bin/safe_mysqld >/dev/null 2>&1 &

```

 *Quote:*   

> Well thought the daemon was running, started it up and get an errror like this: 
> 
> mysql -u root -p 
> 
> Enter password: 
> ...

 

there is a routine to reset the permissions for the root user in the mysql manual... i recommend the commented, searchable html-version of the manual...

----------

## jonny5

I have found the same problem.  If I manually run

```
root@dev etc # /usr/bin/mysqld_safe

Starting mysqld daemon with databases from /var/lib/mysql
```

it starts the server and I guess creates the

```
root@dev mysqld # pwd

/var/run/mysqld

root@dev mysqld # ls

mysqld.pid  mysqld.sock
```

I looked at the /etc/init.d/mysql and it would seem that it starts it the same way... yet doesn't.  It doesn't actually create the mysqld.sock file or the mysqld.pid file in the /var/run/mysqld, does anyone know why?

Also, I am guessing that it wouldn't be too smart to do a screen and then launch mysqld_safe from within.    :Laughing: 

----------

## slartibartfasz

 *jonny5 wrote:*   

> 
> 
> I looked at the /etc/init.d/mysql and it would seem that it starts it the same way... yet doesn't.  It doesn't actually create the mysqld.sock file or the mysqld.pid file in the /var/run/mysqld, does anyone know why?
> 
> 

 

hmm - the script works perfect for me - i guess u execute it as root - if not that may be your problem /var/run is owned by root and drwxr-xr-x - so only root can write to it.

to hunt the thing down u could also tweak the init script a little bit to print errors to stout. change

```

ebegin "Starting mysqld"

        /usr/bin/safe_mysqld >/dev/null 2>&1 &

```

to

```

ebegin "Starting mysqld"

        /usr/bin/safe_mysqld &

```

in /etc/init.d/mysql

----------

## mharrodine

If you're having trouble connecting to your mysql server over a network despite everything being OK on the server itself (i.e. you CAN connect via a socket) try commenting this part of /etc/mysql/my.cnf :-

# keep secure by default!

#bind-address = 127.0.0.1     <--- i.e. comment this line which is uncommented by default!

.

.

(Oh, don't forget to restart mysqld to source the new config afterwards)

It had me foxed for a good couple of hours - the line binds the mysql server to the loopback address preventing access over a network (probably no route back to the client or something). It's damn annoying aswell because it's a Gentoo "enhancement" to the my.cnf script so far as I can tell. First real annoyance i've had with Gentoo in nearly a year of using it. THIS IS SECURITY GONE MAD! The exclamation point on the comment just makes it look like a joke...ha sarcastic ha....

Hope it helps if you were looking for an answer to a mysql problem....

----------

