Jump to content

Archived

This topic is now archived and is closed to further replies.

pacman

Can't connect to mysql

Recommended Posts

I installed mysql and a groupware tool. Everything went fine until I tried to change some permissions to the database...

 

My problem:

 

The Groupware Tool is up and running fine - it\'s ok

But I can\'t connect to mysql with another user or with the mysqladmin...

 

Error message:

[root@localhost mysql]# mysql

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

[root@localhost mysql]#

 

Mysql is running:

[root@localhost mysql]# ps -ef | grep mysql

root 941 1 0 Feb20 ? 00:00:00 /bin/sh /usr/bin/safe_mysqld --d

mysql 7391 941 0 Feb21 ? 00:00:00 /usr/libexec/mysqld --defaults-f

mysql 7393 7391 0 Feb21 ? 00:00:00 /usr/libexec/mysqld --defaults-f

mysql 7394 7393 0 Feb21 ? 00:00:01 /usr/libexec/mysqld --defaults-f

mysql 7395 7393 0 Feb21 ? 00:00:00 /usr/libexec/mysqld --defaults-f

root 17415 16950 0 17:12 pts/0 00:00:00 grep mysql

 

and the .sock file exists:

 

[root@localhost mysql]# ls -l /var/lib/mysql/mysql.sock

-rwxrwxrwx 1 mysql mysql 0 Feb 27 16:34 /var/lib/mysql/mysql.sock

[root@localhost mysql]#

 

If I try to connect via PHPmyAdmin I get the message

 

Server localhost

Error

 

MySQL said:

 

 

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

 

Maybe I have to explain how this situation was coming up...

 

I had the whole installation working with localhost permissons for access to mysql. I tried to change this via Webmin that I can access the DB from a Gui outside this host. I think I took all permissions from the super user (Don\'t know how :roll: ).

 

Is it possible to rebuild the user table? Without affect to the running Groupware?

 

Regards

Frank

Share this post


Link to post
Share on other sites

Run the mysql_install_db in the mysql/bin directory...

 

It will reset the users table to the original, with the root user having a blank password.

 

You may then connect using

 

mysql -h localhost -u root

 

and add your own users etc.

 

P.

Share this post


Link to post
Share on other sites

Thanks for your answer.

 

If I do that, is the new user which I have created for the Groupware affected?

Share this post


Link to post
Share on other sites

Ok, I did it, but I still get the message:

 

[root@localhost bin]# ./mysqladmin status

./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!

[root@localhost bin]#

 

BUT MySQL is running:

 

[root@localhost bin]# ps -ef |grep mysql

root 941 1 0 Feb20 ? 00:00:00 /bin/sh /usr/bin/safe_mysqld --d

mysql 7391 941 0 Feb21 ? 00:00:00 /usr/libexec/mysqld --defaults-f

mysql 7393 7391 0 Feb21 ? 00:00:00 /usr/libexec/mysqld --defaults-f

mysql 7394 7393 0 Feb21 ? 00:00:01 /usr/libexec/mysqld --defaults-f

mysql 7395 7393 0 Feb21 ? 00:00:00 /usr/libexec/mysqld --defaults-f

root 18411 18342 0 10:16 pts/0 00:00:00 grep mysql

[root@localhost bin]#

Share this post


Link to post
Share on other sites

I did a reboot and now I don\'t have the socket failure anymore.

 

PHPmyAdmin is also working, but I don\'t have and permissions. I only see the test database and I have no priviledge to change anything...

Share this post


Link to post
Share on other sites

Hi, try the following and then log into phpmyadmin using the biopv user (or your own username - probably a better idea :) )

 

It\'s probably just the grant tables that needs updating...

 

P.

 


Shell>mysql -h localhost -u root  

Welcome to the MySQL monitor.  Commands end with; or g. 

Your MySQL connection id is 14 to server version: 3.23.52 



Type \'help;\' or \'h\' for help. Type \'c\' to clear the buffer. 



mysql> use mysql 

Reading table information for completion of table and column names 

You can turn off this feature to get a quicker startup with -A 



Database changed 

mysql> 

mysql> grant all privileges on *.* to biopv@"%" identified by \'biopv\' with grant option; 

Query OK, 0 rows affected (0.00 sec) 



mysql> 

mysql> 

mysql> grant all privileges on *.* to biopv@localhost identified by \'biopv\' with grant option; 

Query OK, 0 rows affected (0.00 sec) 



Share this post


Link to post
Share on other sites

Hi,

 

this is really help for dummies, thanks :-)

 

But:

 


[root@localhost /root]# mysql -h localhost -u root  

Welcome to the MySQL monitor.  Commands end with; or g.

Your MySQL connection id is 68 to server version: 3.23.36



Type \'help;\' or \'h\' for help. Type \'c\' to clear the buffer



mysql> use mysql 

ERROR 1044: Access denied for user: \'@localhost\' to database \'mysql\'

mysql> 

 

 

I think the user root doesn\'t exist?

 

Frank

Share this post


Link to post
Share on other sites

Hmmm.....

 

You ran the mysql_install_db program and something went wrong ?

 

You should probably back up your data before continuing with anything. Just make a copy of the mysql/var/data or whereever they are stored... (You databases are put in a folder of their own with the database name as folder name).

 

It looks like you could successfully login as root with a blank password, but you do not have permission to use the mysql database ?

 

I\'m not sure if there is a clever solution (probably there is)... otherwise reinstall and then copy the databases you need back (don\'t restore the mysql database, since that\'s most likely what\'s causing the problem).

 

My suggestion:

 

Find the directory where you can see the folders named

 

test

mysql

yourdb (whatever dbs you created).

 

DELETE the mysql folder (i.e. the user tables, grant tables etc.)

 

Run mysql_install_db again

 

Check to see that a new folder has been generated, with new users etc...

 

If this doesn\'t work - I\'m lost.... But as I said, BACKUP first!

 

P.

Share this post


Link to post
Share on other sites

Hi biopv,

 

I have it done but I have the same result as above...

 

Maybe I\'ll install the whole thing from scratch :cry:

 

Frank

Share this post


Link to post
Share on other sites

Hi there

I am only a newbie so apologies if this is obvious, but I have seen a post that suggests checkingyour permissions on the mysql directory. If it is read only then this might be causing the error.

Mike

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.