一、scr 屏幕输出日志【方便查看执行过程中有没有错】
二、【必须依赖包】
rm -rf /etc/yum.repos.d/*
cat <<EOF > /etc/yum.repos.d/base.repo
[Base]
name=base
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
EOF
mount /dev/cdrom /mnt
yum install -y make* gcc* ncurses-devel* gcc-c++*
三、
1.安装cmake
(mysql5.5以后是通过cmake来编译的)
下载解压cmake-2.8.5.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
tar zxf /tmp/cmake-2.8.12.2.tar.gz -C /usr/local/src
cd /usr/local/src/cmake-2.8.12.2/
./configure --prefix=/usr/local/cmake
echo $?
make && make install
echo $?
export PATH=/usr/local/cmake/bin:$PATH
2.安装mysql
下载地址:http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz
groupadd mysql
useradd -s /sbin/nologin -g mysql mysql
cd /tmp
tar xf /tmp/mysql-5.6.17.tar.gz
cd /tmp/mysql-5.6.17
cmake
-DCMAKE_INSTALL_PREFIX=/app/mysql
-DMYSQL_DATADIR=/app/mysql/data
-DMYSQL_UNIX_ADDR=/app/mysql/data/mysql.sock
-DENABLED_LOCAL_INFILE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_EXAMPLE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-DMYSQL_TCP_PORT=3306
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DMYSQL_USER=mysql
-DWITH_DEBUG=0
*********************z编译参数说明******************
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql #安装的根目录
-DMYSQL_DATADIR=/usr/local/mysql/data #数据存放目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock #UNIX socket文件
-DENABLED_LOCAL_INFILE=1 #启用加载本地数据
-DWITH_INNOBASE_STORAGE_ENGINE=1 #支持InnoDB引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 #支持ARCHIVE引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 #支持BLACKHOLE引擎
-DWITH_FEDERATED_STORAGE_ENGINE=1 #支持FEDERATED引擎
-DWITH_EXAMPLE_STORAGE_ENGINE=1 #支持EXAMPLE引擎
-DWITH_PARTITION_STORAGE_ENGINE=1 #支持PARTITION引擎
-DWITH_MYISAM_STORAGE_ENGINE=1 #支持MYISAM引擎
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 #支持PERFSCHEMA引擎
-DMYSQL_TCP_PORT=3306 #对外开放的默认端口
-DEXTRA_CHARSETS=all #支持所有扩展字符支持
-DDEFAULT_CHARSET=utf8 #默认字符集为utf8
-DDEFAULT_COLLATION=utf8_general_ci #默认字符校对utf8
-DMYSQL_USER=mysql #指定mysql启动用户
-DWITH_DEBUG=0 #调试模式
**************************************************
# make && make install
# chown -R mysql.mysql /app/mysql
# cd /app/mysql/scripts/
# ./mysql_install_db --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data #初始化mysql数据库,#指定mysql数据文件的存放位置
# cd ..
# cd support-files/
# cp mysql.server /etc/rc.d/init.d/mysql
# cp my-default.cnf /etc/my.cnf
# chkconfig --add mysql
# chkconfig mysql on
# service mysql start
# ln -s /app/mysql/bin/* /usr/bin/
mysqladmin -u root password 'mysql' #设置数据库root密码为mysql#
mysql -u root -pmysql
删除test和匿名帐户
mysql> DROP DATABASE test;
mysql> DELETE FROM mysql.user WHERE user = '';
mysql> FLUSH PRIVILEGES;
修改配置文件
vi /etc/my.cnf
[mysqld]
datadir=/app/mysql/data
socket =/app/mysql/data/mysql.sock
lower_case_table_names=1
character-set-server=utf8
collation-server=utf8_general_ci
[client]
default-character-set=utf8
socket =/app/mysql/data/mysql.sock
【 mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!】
[mysql.server]
user=mysql
basedir=/app/mysql
default-character-set=utf8
[mysqld_safe]
err-log=/app/mysql/errlog/mysqld.log