我目前使用的mysql统一都是安装在Linux系统上的,使用的版本是RHEL6.3
1、在mysql服务端安装好mysql,做好相应的设置在mysql服务端创建了一个用户并授予相应的权限
mysql> GRANT ALL PRIVILEGES *.* TO 'menger'@'%' IDENTIFIED BY 'menger';
mysql> FLUSH PRIVILEGES;
在客户段安装了mysql,想用mysql连接服务端
# mysql -umenger -p -h192.168.6.25
报错:ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.6.25' (113)
查看授权正确,也刷新了授权,用Client机器也能ping同Server端机器
[root@mysql2 ~]# ping 192.168.6.25
PING 192.168.6.25 (192.168.6.25) 56(84) bytes of data.
64 bytes from 192.168.6.25: icmp_seq=1 ttl=64 time=24.3 ms
64 bytes from 192.168.6.25: icmp_seq=2 ttl=64 time=0.243 ms
64 bytes from 192.168.6.25: icmp_seq=3 ttl=64 time=0.234 ms
64 bytes from 192.168.6.25: icmp_seq=4 ttl=64 time=0.268 ms
64 bytes from 192.168.6.25: icmp_seq=5 ttl=64 time=0.281 ms
64 bytes from 192.168.6.25: icmp_seq=6 ttl=64 time=0.154 ms
经过查看资料了解到是防火墙的问题
我关闭了防火墙和selinux之后,可以正确连接
[root@mysql ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules:
使重启之后仍生效
chkconfig iptables off
查看selinux状态
[root@mysql ~]# sestatus -v
SELinux status: enforcing
[root@mysql ~]# setenforce 0
编辑配置文件,使永久生效
[root@mysql ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
最后,从Client端成功连接Server端
2、使用二进制源码包安装好mysql,启动时报错
[root@mysql mysql]# /etc/init.d/mysqld startStarting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/mysql.com.pid)
查看/usr/local/mysql/data/mysql.com.err会发现报错信息
[root@mysql data]# cat mysql.com.err
160801 06:23:43 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2016-08-01 06:23:57 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-01 06:23:57 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.32) starting as process 3572 ...
2016-08-01 06:23:57 3572 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2016-08-01 06:23:57 3572 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-08-01 06:23:57 3572 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-08-01 06:23:57 3572 [Note] InnoDB: The InnoDB memory heap is disabled
2016-08-01 06:23:57 3572 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-01 06:23:57 3572 [Note] InnoDB: Memory barrier is not used
2016-08-01 06:23:57 3572 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-08-01 06:23:57 3572 [Note] InnoDB: Using Linux native AIO
2016-08-01 06:23:57 3572 [Note] InnoDB: Using CPU crc32 instructions
2016-08-01 06:23:57 3572 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-08-01 06:23:57 3572 [Note] InnoDB: Completed initialization of buffer pool
2016-08-01 06:23:57 3572 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode
2016-08-01 06:23:57 3572 [ERROR] InnoDB: The system tablespace must be writable!
2016-08-01 06:23:57 3572 [ERROR] Plugin 'InnoDB' init function returned error.
2016-08-01 06:23:57 3572 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-08-01 06:23:57 3572 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-08-01 06:23:57 3572 [ERROR] Aborting
...
...
...
发现是权限问题: errno: 13 - Permission denied
于是我把/usr/local/mysql文件的用户和属组都改成了mysql
[root@mysql ~]#chown -R mysql:mysql /usr/local/mysql
结果还是报一样的错误,之后我使用mysql用户重新初始化了一次
[root@mysql mysql]# su - mysql
-bash-4.1$ cd /usr/local/mysql
-bash-4.1$ scripts/mysql_install_db
就可以启动了
[root@mysql mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS