Mysql failure on OSX 10.6 development machine: "ERROR 2002 (HY000): cannot connect to local MySQL server through socket" /tmp/mysql.sock "(2)"

I installed MySQL on my personal / development machine using the .dmg package, as instructed here: http://dev.mysql.com/doc/refman/5.5/en/macosx-installation-pkg.html , including installation launch item and settings panel. And yet, I cannot use MySQL at all.

works:

/Library/StartupItems/MySQLCOM/MySQLCOM start 

or

 /Library/StartupItems/MySQLCOM/MySQLCOM restart 

"works" - in this he gives me a message like "Starting the MySQL database server", but then I still can’t enter mysql on the command line or connect to it in Rails 2.3.8 application running in script / server. I get the error indicated in the title of the question.

In addition, the MySQL settings panel does not work either. If I click the "Start MySQL Server" button, they will ask me to enter my password, but then nothing will happen - the panel continues to say that the server is stopped.

(I believe that I had a version of MySQL for MacPorts installed earlier, and it is also possible that there was one source in the past, but I'm sure I deleted them and deleted all the files associated with it that I could find. )

I am also trying mysqld start in terminal. here is the conclusion:

 110127 15:40:28 [Warning] Can't create test file /usr/local/mysql-5.5.8-osx10.6-x86_64/data/Lucky-Charm.lower-test 110127 15:40:28 [Warning] Can't create test file /usr/local/mysql-5.5.8-osx10.6-x86_64/data/Lucky-Charm.lower-test 110127 15:40:28 [Note] Plugin 'FEDERATED' is disabled. mysqld: Can't find file: './mysql/plugin.frm' (errno: 13) 110127 15:40:28 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. InnoDB: The InnoDB memory heap is disabled InnoDB: Mutexes and rw_locks use GCC atomic builtins InnoDB: Compressed tables use zlib 1.2.3 110127 15:40:28 InnoDB: Initializing buffer pool, size = 128.0M 110127 15:40:28 InnoDB: Completed initialization of buffer pool 110127 15:40:28 InnoDB: Operating system error number 13 in a file operation. InnoDB: The error means mysqld does not have the access rights to InnoDB: the directory. InnoDB: File name ./ibdata1 InnoDB: File operation call: 'open'. InnoDB: Cannot continue operation. 

Tried to follow mysql_upgrade start message, but this again gives me the original error.


UPDATE:

OK. I pursued the theory that this is a permission issue. Seeing that datadir belongs to root, I chown -R is _mysql. In response to Mike, here where he stands now:

 $ ls -al /usr/local/mysql-5.5.8-osx10.6-x86_64 total 296 drwxr-xr-x 16 root wheel 544 Dec 3 12:53 . drwxrwxr-x 12 root staff 408 Jan 27 14:38 .. -rw-r--r-- 1 root wheel 17987 Dec 3 11:58 COPYING -rw-r--r-- 1 root wheel 12388 Dec 3 11:58 INSTALL-BINARY -rw-r--r-- 1 root wheel 113534 Dec 3 11:58 README drwxr-xr-x 44 root wheel 1496 Dec 3 12:53 bin drwxr-xr-x 9 _mysql wheel 306 Jan 27 16:46 data drwxr-xr-x 4 root wheel 136 Dec 3 12:53 docs drwxr-xr-x 47 root wheel 1598 Dec 3 12:53 include drwxr-xr-x 12 root wheel 408 Jan 27 14:38 lib drwxr-xr-x 4 root wheel 136 Dec 3 12:53 man drwxr-xr-x 19 root wheel 646 Jan 27 14:38 mysql-test drwxr-xr-x 3 root wheel 102 Dec 3 12:53 scripts drwxr-xr-x 32 root wheel 1088 Dec 3 12:53 share drwxr-xr-x 28 root wheel 952 Dec 3 12:53 sql-bench drwxr-xr-x 16 root wheel 544 Dec 3 12:53 support-files 

I tried to make mysqld start in the terminal because it was the only thing that gave me something that seemed to be meaningful output of error messages (see https://gist.github.com/799436 ), but in #mysql they told me that it is not intended to be run directly (and if I try sudo mysqld start , I get a message embroidering me from trying to start mysql as root).

Something seems to be working for me now: mysqld_safe & successfully starts the MySQL server. What else does not work is the "normal" method of starting the server (the "Start" or "Settings" element)

... leading someone in #mysql to tell me that apparently MySQL is ok, this is the startup item that is borked.

+4
source share
2 answers

Well, there were a few things, mainly with rights / property rights, that tried to make working with binary MySQL useful.

You may need to make sure that the startup item is owned by root:

 sudo chown -R root:wheel /Library/StartupItems/MySQLCOM 

Perhaps you need a /etc/my.cnf file with this in it:

 [mysqld] socket=/tmp/mysql.sock datadir=/usr/local/mysql/data 

You may need to populate these variables in / usr / local / mysql / support -files / mysql.server (the line will be there with empty values):

 basedir=/usr/local/mysql datadir=/usr/local/mysql/data 

(see can't start MySql on Mac OS 10.6 Snow Leopard relatively higher)

This may be enough to do this, but if not, try to make sure that the mysql user (_mysql) can write to the data directory (owns it and has write permissions to everything in it).

In any case, now the settings panel and the launch element actually work for me.


Having gone through this a second time on another machine, I made some changes and removed the unnecessary bit from what I answered yesterday.

In general, here I suggest that you make binary MySQL work well in OSX 10.6. Warning, you may end up deleting all the databases that you already had in the first couple of steps, but since this is intended for your development machine, this should not be a big problem. Start mysqldump first if you need to.

  • Make sure you don't have a mysql server that is running right now: ps aux | grep mysql ps aux | grep mysql will show you its processes. Stop it with mysqladmin shutdown , or if this does not work because something is running, sudo kill process numbers.
  • Uninstall all previous installed mysql versions - check port list installed , check if installed for homebrew, sudo find / -name mysql looks for compiled sources and delete them, whatever it takes. You can even remove the startup item by deleting the /Library/StartupItems/MySQLCOM if you wish.
  • Run the mysql-whatever-version.pkg installation package
  • Test it by typing sudo mysqld_safe & on the terminal. If you get a "not found" command, add /usr/local/mysql/bin to your path and try again. If you receive error messages, check the /etc/my.cnf file as described above and try again. If it still doesn't work, perhaps try recursively chowning and chmoding the /usr/local/mysql/data directory to make sure _mysql can write to it. After you run it, click "OK", enter mysql into the terminal. If you get the MySQL command line, everything will be fine (type exit to get out of it) - in fact, if you get something other than ol “Unable to connect to the local MySQL server via socket”, then you can come to I conclude that the MySQL server is working - shut down or kill the server and move on.
  • Then we will set the launch element. Run MySQLStartupItem.pkg
  • Check the launch item on the terminal by typing sudo /Library/StartupItems/MySQLCOM/MySQLCOM start . It will give you a message that it is starting the server, but if it is unsuccessful, it will not give you any instructions, so try logging into mysql again to check if the server is working. If so, enter sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop to stop the server (and check that the start item can stop the server and also start it: D) ​​If it does not work, try the above settings in /usr/local/mysql/support-files/mysql.server . If this still fails, try the bit at the top next to sudo chown -R root:wheel /Library/StartupItems/MySQLCOM .
  • Once this works, run / install MySQL.prefPane. This should give you the MySQL element in your system settings below, and if you go there, you should see a button that you can click to stop / start the MySQL server. Give it a try, and if that doesn't work by now, I'm not sure what else I can tell you.
+9
source

I got the same error after deleting the old old ports and installing mysql in the new Mac ports directory (new / opt / local).

I fixed it by setting the correct permissions for mysql directories in the ports tree:

 chown -R _mysql:_mysql /opt/local/var/db/mysql5 chown -R _mysql:_mysql /opt/local/var/run/mysql5/ chmod -R 755 /opt/local/var/run/mysql5 

I'm not sure if chmod is needed. Of course, the ports have already done the work of creating the user and group _mysql.

0
source

Source: https://habr.com/ru/post/1337386/


All Articles