启动mysql 报错:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
---------------------------------网上的解决办法-1-------------------------------------------------------------------
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.
另外看看是不是权限问题.
2、确定你的mysql.sock是不是在那个位置,
mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock
3、试试:service mysqld start
4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start
启动 MySQL: [ 确定 ]
[root@localhost ~]# mysql -uroot -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
原因是,/var/lib/mysql 的访问权限问题。
shell> chown -R mysql:mysql /var/lib/mysql
接着启动服务器
shell> /etc/init.d/mysql start
服务器正常启动后察看 /var/lib/mysql 自动生成mysql.sock文件。
但是我的问题仍然没有得到解决。
问题终于解决:
方法: 修改/etc/my.conf:
[mysqld]
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
[mysql.server]
user=mysql
basedir=/usr/local/mysql
If there is not currently a section called [client], add one at the bottom of the file and copy the socket= line under the [mysqld] section such as:
发现依旧如此,运行/etc/init.d/mysql start报错: Starting MySQLCouldn't find MySQL manager or server
是mysqld服务没启,运行/usr/local/mysql/bin/mysqld_safe &
问题解决。
---------------------------------网上的解决办法-2-------------------------------------------------------------------
把数据库的链接地址从localhost改为127.0.0.1
-------------------------------------最后使用的方法--------------------------------------------------------
现象描述:
lost connection to mysql server at 'handshark:reading inital'
网站访问出现如题错误,经过检查my.cnf,发现innodb_buffer_pool_size = 2048M 设置过大,调整为innodb_buffer_pool_size = 1024M即可,网上也有该问题的其他解决方法,但都不能解决我的问题
解决方法之一:
网站访问出现如题错误,经过检查my.cnf,发现innodb_buffer_pool_size = 2048M 设置过大,调整为innodb_buffer_pool_size = 1024M即可,网上也有该问题的其他解决方法,但都不能解决我的问题。
Lost connection to MySQL server at 'reading initial communication packet' 错误解决
上次解决了这个问题,今天又碰到,突然失忆,又做了一番无用功后终于搞定,这次一定要记录下来,免得下次又浪费时间
1、修改mysql配置文件
vi /etc/my.cnf
[mysqld]段加skip-name-resolve
在这个之前要把mysql的远程访问权限打开,或者再加skip-grant-table(不推荐)
2、修改hosts.allow
vi /etc/hosts.allow
加mysqld : ALL : ALLOW
mysqld-max : ALL :ALLOW
其它网友的补充:
mysql教程 'reading initial communication packet'错误解决方法
出现这种问题是服务器突然关掉出现的问题,
错误提示是:
无法链接数据库教程(mysql)服务器, 请检查服务器地址、用户名、密码.
代码: 2013
错误: lost connection to mysql server at 'reading initial communication pa(www.jb51.net)cket', system error: 0
140321 13:19:31 mysqld_safe Starting mysqld daemon with databases from
/var/lib/mysql
/usr/libexec/mysqld
: Can
't find file: '
.
/mysql/plugin
.frm' (errno: 13)
140321 13:19:31 [ERROR] Can't
open
the mysql.plugin table. Please run mysql_upgrade to create it.
140321 13:19:31 InnoDB: Initializing buffer pool, size = 8.0M
140321 13:19:31 InnoDB: Completed initialization of buffer pool
140321 13:19:31 InnoDB: Started; log sequence number 0 44233
140321 13:19:31 [ERROR]
/usr/libexec/mysqld
: Can
't find file: '
.
/mysql/host
.frm' (errno: 13)
140321 13:19:31 [ERROR] Fatal error: Can
't open and lock privilege tables: Can'
t
find
file
:
'./mysql/host.frm'
(errno: 13)
140321 13:19:31 mysqld_safe mysqld from pid
file
/var/run/mysqld/mysqld
.pid ended
mysql 的数据库存放目录默认是 /var/lib/mysql,这个目录也被定义为 mysql 的根目录,/usr/bin/mysqld_safe 负责启动进程,/usr/libexec/mysqld 执行文件负责连接 mysql,它要读取 /var/lib/mysql/mysql/plugin.frm 文件,这里显示找不到这个文件,但是我进入那个目录看过,plugin.frm 文件是实际存在的。
各种尝试之后,我终于想到了,mysqld 进程(不是/usr/libexec/mysqld)所属的用户和组都是 mysql,那么/var/lib/mysql/mysql/ 目录内的文件也应该属于 mysql 用户和 mysql 组。修改一下
1
|
chown
mysql:mysql *
|
果然好了
1
2
3
4
5
6
7
|
140321 13:24:42 mysqld_safe Starting mysqld daemon with databases from
/var/lib/mysql
140321 13:24:43 InnoDB: Initializing buffer pool, size = 8.0M
140321 13:24:43 InnoDB: Completed initialization of buffer pool
140321 13:24:43 InnoDB: Started; log sequence number 0 44233
140321 13:24:43 [Note] Event Scheduler: Loaded 0 events
140321 13:24:43 [Note]
/usr/libexec/mysqld
: ready
for
connections.
Version:
'5.1.73'
socket:
'/var/lib/mysql/mysql.sock'
port: 3306 Source distribution
|