Mysql
如何在 Mac OS X 10.6.8 上啟動 MySQL?
我按照本教程在 Mac OS X 10.6.8 上安裝 MySQL。現在我得到他以下錯誤:
$ mysqladmin version /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists! $ ls /tmp/mysql.sock ls: /tmp/mysql.sock: No such file or directory
和
$ /Library/StartupItems/MySQLCOM/MySQLCOM stop Stopping MySQL database server $ /Library/StartupItems/MySQLCOM/MySQLCOM start Starting MySQL database server $ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
和
$ mysqladmin ping /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists! $ mysqladmin -uroot ping /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists! $ mysqladmin -uroot -h127.0.0.1 ping /usr/local/mysql/bin/mysqladmin: connect to server at '127.0.0.1' failed error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 61' $ mysqladmin -uroot -h127.0.0.1 --protocol=tcp ping /usr/local/mysql/bin/mysqladmin: connect to server at '127.0.0.1' failed error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 61' $ ls /usr/local/mysql mysql/ mysql-5.0.95-osx10.5-x86_64/ $ ls /usr/local/mysql/ COPYING README configure docs/ lib/ mysql-test/ share/ support-files/ INSTALL-BINARY bin/ data/ include/ man/ scripts/ sql-bench/ tests/ $ find /usr/local/mysql/ -name mysql.sock find: /usr/local/mysql//data: Permission denied $ sudo find /usr/local/mysql/ -name mysql.sock Password: $
另外,我無法登錄 MySQL:
$ mysql -uroot ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) $ mysql -uroot -h127.0.0.1 ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61) $ mysql -uroot -h127.0.0.1 --protocol=tcp ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)
和
$ /Library/StartupItems/MySQLCOM/MySQLCOM stop Stopping MySQL database server $ /Library/StartupItems/MySQLCOM/MySQLCOM start --skip-grant-tables Starting MySQL database server $ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) $ sudo ls -l /usr/local/mysql/data/*.err Password: ls: /usr/local/mysql/data/*.err: No such file or directory
回复:@Matt Fenwick
$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop Stopping MySQL database server $ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start Starting MySQL database server $ sudo mysqld -u root 120327 13:03:48 [Warning] Ignoring user change to 'root' because the user was set to 'mysql' earlier on the command line 120327 13:03:48 [Warning] Setting lower_case_table_names=2 because file system for /Volumes/storage/Data/ is case insensitive $ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) $ sudo mysqld -u mysql 120327 13:04:11 [Warning] Setting lower_case_table_names=2 because file system for /Volumes/storage/Data/ is case insensitive $ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) $
my.cnf
用過的[mysql] max_allowed_packet=128M socket=/tmp/mysql.sock [mysqld] user=mysql datadir=/Volumes/storage/Data log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid #socket=/var/lib/mysql/mysql.sock socket=/tmp/mysql.sock innodb_log_file_size=256M skip-locking skip-bdb delay-key-write=OFF interactive_timeout=3600 wait_timeout=3600 thread_cache_size=128 table_cache=2048 skip-external-locking max_connections=800 key_buffer_size=64M read_buffer_size=1M sort_buffer_size=2M join_buffer_size=1M read_rnd_buffer_size=2M bulk_insert_buffer_size=10M tmp_table_size=64M max_heap_table_size=64M max_connect_errors=5000 max_allowed_packet=128M innodb_data_file_path=ibdata1:256M:autoextend innodb_buffer_pool_size=1G innodb_log_file_size=512M innodb_flush_log_at_trx_commit=2 innodb_open_files=1000
我遇到了完全相同的問題(儘管我在 Mac OS X 10.5.8 上),並帶有所有相同的錯誤消息。
原來問題是當電腦開機時,MySQL沒有自動啟動。
我通過手動啟動 MySQL 解決了這個問題:
prompt$ sudo mysqld -u root <secure password goes here!>
請注意:如果沒有對
sudo
電腦和 MySQL 本身的root 訪問權限,MySQL 不會讓我啟動伺服器(不是我在抱怨,但在我弄清楚之前這只是令人沮喪)。另請注意,該程序是mysqld,而不是.mysql
執行該命令後,一切對我來說都很好。
如果您使用磁碟映像 (.dmg) 文件安裝了 MySQL 伺服器,則:
使用終端應用程序(bash):
sudo su - nohup /usr/local/mysql/bin/mysqld_safe & exit