准备工作:
网络源使用163,sohu
安装依赖包:
rpm -ivh http://mirrors.ustc.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
tar xvf http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz
yum -y install ntp cmake make openssl openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ flex bison bzip2 bzip2-devel libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
1、创建mysql用户及用户组
useradd -M -s /sbin/nologin mysql
2、创建mysql数据库存放目录
mkdir -p /data/mysql #存放数据库
3、解压安装mysql
tar -zxvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.31-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
make && make install
//使用cmake则需要使用CMAKE参数,以下说明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //默认安装目录
-DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校验字符
-DEXTRA_CHARSETS=all //安装所有扩展字符集
-DENABLED_LOCAL_INFILE=1 //允许从本地导入数据
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
//CMAKE详细介绍参见
注意事项:
如安装失败重新编译时,需要清除旧的对象文件和缓存信息。
make clean
rm -f CMakeCache.txt
rm -rf /etc/my.cnf
4、设置目录权限并创建系统数据库的表
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mysql
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql //将mysql的启动服务添加到系统服务中
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql
5、设置环境变量
vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
source /etc/profile
7、开启mysql服务
shell> service mysql start
Starting MySQL....... [确定]
shell> chkconfig --add mysql //加入开机启动服务
8、修改MySQL的root用户的密码以及打开远程连接
shell> mysql -u root mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "passwd";
Query OK, 0 rows affected (0.09 sec)
mysql> update user set password=password('passwd') where user='root';
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
shell>mysql -u root -p
Enter password:
(责任编辑:最模板) |