安装环境:
ubuntu 桌面版13.04
安装版本:
mysql-5.6.12.tar.gz1.
安装必备工具:
- sudo apt-get install cmake libncurses5-dev bison g++
2 添加组和用户及安装目录权限
- sudo groupadd mysql #添加组
- sudo useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
- sudo mkdir -p /usr/local/mysql #创建MySQL安装目录
- sudo mkdir -p /usr/local/mysql/data #创建MySQL安装目录
- sudo chown -R mysql:mysql /usr/local/mysql/data #设置MySQL数据库目录权限
3 编译安装ysql
- cd /usr/local/src
- sudo wget http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz
3.1 解压MySQL
- sudo tar -zxvf mysql-5.6.12.tar.gz
- sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DWITH_DEBUG=0
- sudo make -j4 #-j 数字 表示以多核心运行
- sudo make install
4.相关设置
4.1配置开机启动
- sudo cp ./support-files/my-default.cnf /etc/my.cnf
- sudo cp ./support-files/mysql.server /etc/init.d/mysqld #把Mysql加入系统启动
- sudo chmod 755 /etc/init.d/mysqld
- sudo chkconfig mysqld on
- sudo ln -s /usr/local/mysql/bin/mysql /usr/bin
- sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
- sudo /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --skip-name-resolve --user=mysql
- sudo vi /etc/my.cnf
- #增加默认存储类型和去掉反向解析
- default-storage-engine=MyISAM
- skip-name-resolve