wget http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.22-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.22-1.el6.x86_64.rpm yum -y install mysql-community-server
service mysqld start
service mysqld stop
service mysqld status
显示系统中与mysql相关的进程
ps aux | grep mysql
mysql启动过程可能会报错,这里需要到其启动日志中查看详细信息,查看方式如下
less /var/log/mysqld.log
Mysql的配置文件在/etc/my.cnf文件中,可以对这个文件中的参数进行修改来自行配置mysql
如果想卸载已经安装的mysql,可使用以下命令进行卸载
yum remove mysql
新安装的mysql,可以通过以下命令设置root账号的密码
mysqladmin -r root password 'you password'
安装完成,在第一次通过service mysqld start命令启动mysql的过程中可能会遇到这个问题。通过以下步骤进行处理:
(1)查看启动日志
如3.4所述,查看mysqld.log中记录的启动详情。
InnoDB: mmap(137363456 bytes) failed; errno 12
130716 17:09:53 InnoDB: The InnoDB memory heap is disabled
130716 17:09:53 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130716 17:09:53 InnoDB: Compressed tables use zlib 1.2.3
130716 17:09:53 InnoDB: Initializing buffer pool, size = 128.0M
130716 17:09:53 InnoDB: Completed initialization of buffer pool
130716 17:09:53 InnoDB: highest supported file format is Barracuda.
130716 17:09:53 InnoDB: Waiting for the background threads to start
130716 17:09:54 InnoDB: 1.1.8 started; log sequence number 4703029
130716 17:09:54 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130716 17:09:54 [Note] - '0.0.0.0' resolves to '0.0.0.0';
130716 17:09:54 [Note] Server socket created on IP: '0.0.0.0'.
130716 17:09:54 [Note] Event Scheduler: Loaded 0 events
130716 17:09:54 [Note] /usr/local/mysql-DMYSQL_DATADIR=/var/mysql-DMYSQL_UNIX_ADDR=/var/mysql/mysqld.sock/bin/mysqld: ready for
connections.
查看内存显示
[root@AY1305070924544 /]# free -m
total used free shared buffers cached
Mem: 995 928 66 0 6 19
-/+ buffers/cache: 903 91
Swap: 0 0 0
重启错误提示
[root@AY1305070924544 /]# /etc/init.d/mysqld start
Starting MySQL. ERROR! The server quit without updating PID file (/var/mysql/data/AY1305070924544.pid).
[root@AY1305070924544 /]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL. ERROR! The server quit without updating PID file (/var/mysql/data/AY1305070924544.pid).
这个其实日志里面说的很明白就是 mysql要占用内存的时候 物理内存不够用导致的 所有 vi /etc/my.cnf
[inonodb]
innodb_buffer_pool_size=64MB 把这个数值改小高版本的默认是128mb。
前一小节提到,将innodb_buffer_pool_size改成比较小的值(比如64M)可以解决无法启动的问题。
不过如果这个值如果设置的太小(比如前面设置的64M)可能会出现mysql运行的过程中报以下错误:
No connection. Trying to reconnect... ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) ERROR: Can't connect to the server
这时将原来的值适应调大一点就可以解决这个问题了。
目前我将64M改成100M后,就没有再报这个错误了。