1.下载
mysql:http://www.mysql.com/downloads/ (须要注冊ORACLE账号)
版本号:mysql-advanced-5.6.21-linux-glibc2.5-x86_64.tar.gz
Linux版本号:centos6.4 x64
2.安装
2.1通过SSH将mysql-advanced-5.6.21-linux-glibc2.5-x86_64.tar.gz上传到linux中/usr/local/文件夹下
2.2清楚原有的mysql:yum remove mysql
2.3安装mysql依赖包:
[root@localhost ~]# yum install gcc
[root@localhost ~]# yum install gcc-c++
[root@localhost ~]#yum installcmake
2.4添加mysql组和用户
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
2.5mysql解压安装重命名
[root@localhost ~]# tar -zxvf mysql-advanced-5.6.21-linux-glibc2.5-x86_64.tar.gz
[root@localhost ~]# mv mysql-advanced-5.6.21-linux-glibc2.5-x86_64.tar.gz mysql
2.6编译安装
[root@localhost mysql]# make && make install
2.7进入安装文件夹。将程序二进制的全部权改为root,数据文件夹的说有权改为mysql用户,更新授权表
[root@localhost mysql]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
安全启动MySQL(默认password为空)
[root@localhost mysql]#./bin/mysqld_safe --user=mysql&
2.8错误:
120908 00:16:25 mysqld_safe Logging to '/usr/local/mysql/data/CentOS.err'.
120908 00:16:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
解决方法:将Centos.err的用户权限改为mysql用户
[root@localhost ~]# cd /usr/local/mysql/data
[root@localhost data]# chgrp -R mysql CentOS.err
连接本机MySQL
[root@localhost mysql]#mysql –u root –p
提示输入password。默觉得空,按Enter就可以
断开连接
mysql>exit;
2.9为root账户设置password
[root@localhost ~]# cd /usr/local/mysql/bin
[root@localhost mysql]# ./bin/mysqladmin -u root password 123456
Enter Password:123456
2.10
设置选项文件,将配置文件复制到/etc下
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/mysql.cnf
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# chmod +x /etc/init.d/mysql
[root@localhost mysql]# chkconfig mysql on
[root@localhost ~]# service mysql start
[root@localhost ~]# service mysql stop
2.12.安装设置完成。之后使用仅仅需启动-连接-断开-关闭-重新启动。命令例如以下:
[root@localhost mysql]# service mysql start
[root@localhost mysql]# ./bin/ mysql -u root -p123456
mysql>exit;
[root@localhost mysql]# service mysql stop
[root@localhost mysql]# service mysql restart