chenxiaba / mywork

记录平时的笔记
0 stars 0 forks source link

myql #37

Open chenxiaba opened 8 years ago

chenxiaba commented 8 years ago

问题1

$mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

查询日志:

$ mysqld status
mysqld: Can't change dir to '/usr/local/mysql-5.7.9-osx10.9-x86_64/data/' (Errcode: 13 - Permission denied)
2015-10-28T13:45:54.565604Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-10-28T13:45:54.565801Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2015-10-28T13:45:54.565844Z 0 [Note] mysqld (mysqld 5.7.9) starting as process 710 ...
2015-10-28T13:45:54.571094Z 0 [Warning] Can't create test file /usr/local/mysql-5.7.9-osx10.9-x86_64/data/xiaoguaideMBP.lower-test
2015-10-28T13:45:54.571134Z 0 [Warning] Can't create test file /usr/local/mysql-5.7.9-osx10.9-x86_64/data/xiaoguaideMBP.lower-test
2015-10-28T13:45:54.571198Z 0 [ERROR] failed to set datadir to /usr/local/mysql-5.7.9-osx10.9-x86_64/data/
2015-10-28T13:45:54.571210Z 0 [ERROR] Aborting

2015-10-28T13:45:54.571218Z 0 [Note] Binlog end
2015-10-28T13:45:54.573597Z 0 [Note] mysqld: Shutdown complete

修改权限:

chmod 

问题2

$ mysqld status
 Unable to lock ./ibdata1 error: 35

问题3:

$ mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决:

$ chown -R mysql:mysql  /usr/local/mysql 
$ ll /usr/local/mysql
lrwxr-xr-x  1 _mysql  _mysql  26 10 22 07:52 /usr/local/mysql -> mysql-5.7.9-osx10.9-x86_64

如果解决不了,看下mysqld的日志:

$ vim /usr/local/mysql/data/mysqld.local.err 
636 2015-10-28T14:18:40.241332Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
637 Version: '5.7.9'  socket: '/tmp/test.socket'  port: 3306  MySQL Community Server (GPL)

$ vim /etc/my.cnf 
[mysqld]
socket = /tmp/test.socket

注释掉即可
chenxiaba commented 8 years ago

登录mysql成功:

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)