MySQL版本:mysql-5.7.4-m14-winx64
MySQL路径:D:/mysql/mysql-5.7.4-m14-winx64
电脑系统:windows7 旗舰版 sp1 64位系统
my.ini文件配置如下:
[client]
default-character-set=utf8
[mysqld]
port=3306
basedir ="D:/mysql/mysql-5.7.4-m14-winx64/"
datadir ="D:/mysql/mysql-5.7.4-m14-winx64/data/"
tmpdir ="D:/mysql/mysql-5.7.4-m14-winx64/data/"
socket ="D:/mysql/mysql-5.7.4-m14-winx64/data/mysql.sock"
log-error="D:/mysql/mysql-5.7.4-m14-winx64/data/mysql_error.log"
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
innodb_data_home_dir="D:/mysql/mysql-5.7.4-m14-winx64/data/"
innodb_flush_log_at_trx_commit =1
innodb_log_buffer_size=128M
innodb_buffer_pool_size=128M
innodb_log_file_size=10M
innodb_thread_concurrency=16
innodb-autoextend-increment=1000
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
max_allowed_packet = 32M
explicit_defaults_for_timestamp=true
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
在DOS窗口下,输入net start mysql,MySQL服务正常启动。
通过命令:
mysql -uroot -p123456 或者mysql -uroot -p123456 -hlocalhost
能够登陆进mysql,并且执行一般的增删改查功能都正常,执行show processlist;结果如下:
+----+------+----------------+------+---------+------+----------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+----------------+------+---------+------+----------+------------------+
| 1 | root | localhost:3707 | NULL | Query | 0 | starting | show processlist |
+----+------+----------------+------+---------+------+----------+------------------+
不知道为什么这里会是3707
但是执行命令:mysql -uroot -p123456 -h127.0.0.1会报错
错误消息为:ERROR 2004 (HY000): Can't create TCP/IP socket (87)
hosts文件里面没有设置127.0.0.1 localhost(试过了,事实证明根本没用)
有人说是3306端口被占用,我netstat -nao查了一下PID,在任务管理器里面对比,确认是mysqld.exe在用3306,没有其
他程序占用此端口
有人说是防火墙的原因,需要把防火墙关了,看了一下我防火墙是关闭的
有人说是max_connections设置得太小,我设置成1000然后用工具连接mysql依旧报10061错。
有人说是需要执行授权操作,需要执行命令:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'
IDENTIFIED BY '123456' WITH GRANT OPTION;(我也试过了,事实证明,没用)
有人说是因为 my.ini 文件 [mysqld] 项里面没有设置bind-address=127.0.0.1的原因,我也试了,试试证明,如果我
设置了这个,mysql服务都启动不鸟,又有人说设置成bind-address=0.0.0.0,结果一样的,mysql服务都无法启动,然
后我在又试了一下设置bind-address=192.168.1.101(本机IP),依旧是无法启动mysql。
然后,我试着在DOS下执行:
mysqladmin -uroot -p123456 version
或者
mysqladmin -uroot -p123456 -hlocalhost version
提示错误:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Unknown MySQL server host 'localhost' (2)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'
执行:mysqladmin -uroot -p123456 -h127.0.0.1 version
提示错误:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at '127.0.0.1' failed
error: 'Can't create TCP/IP socket (87)'
期间也试着在hosts里面添加127.0.0.1 localhost然后再执行上面的命令,事实证明,跟这个无关。
另外,我试着在DOS里面执行 telnet 127.0.0.1 3306,提示无法打开到主机的连接
但是,我执行 telnet localhost 3306,能够连进去(这里我也是过在hosts文件里面添加
127.0.0.1 localhost,事实证明跟这个也没关系)
求大神解答,该怎么解决。
--转自