标签:
1.先检查系统有没有安装mysql
[root@iZ2873rjubzZ opt]# rpm -qa|grep mysql
# 我们看到,并没有安装mysql,但是有一个mysql的libs开发包插件,他是干什么的呢?
# 解释:由于CentOS6.4系统自带就有postfix服务,而这个mysql-libs呢就是支持这个postfix服务的,如果我们不使用到postfix,那就卸载掉吧,而且每一个mysql-server安装的时候,后自带安装上这个mysql-libs。
#删除mysl-;ib,系统就干净了
[root@iZ2873rjubzZ opt]# yum remove mysql-libs
2 下载mysql-5.6.21.tar.gz, 我们准备安装在/user/local 数据放在/uer/local/data 下
[root@iZ2873rjubzZ ~]# groupadd mysql #创建用户组mysql [root@iZ2873rjubzZ ~]# useradd -g mysql mysql -s /bin/false #创建用户mysql 不能远程登录 [root@iZ2873rjubzZ ~]# mkdir /usr/local/mysql [root@iZ2873rjubzZ ~]# mkdir /usr/local/mysql/data [root@iZ2873rjubzZ ~]# cp mysql-5.6.21.tar.gz /usr/local
[root@iZ285pj7jhrZ ~]# cd /usr/local/
[root@iZ285pj7jhrZ local]# tar -xzvf mysql-5.6.21.tar.gz #解压
#安装cmake编译环境和依赖包
[root@iZ285pj7jhrZ local]# yum -y install make gcc-c++ cmake openssl openssl-devel bison-devel ncurses ncurses-devel wget perl perl-devel
3.开始编译安装mysql
cmake --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DENABLE_PROFILING=1 -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
[root@iZ2873rjubzZ mysql-5.6.21]# make && make install #等待较长时间
[root@iZ2873rjubzZ mysql-5.6.21]# make clean #安装完后 清理一下临时文件
4.配置mysql
[root@iZ2873rjubzZ local]# chown -R mysql:mysql /usr/local/mysql #修改mysql目录的所属用户权限
#初始化脚本
[root@iZ2873rjubzZ data]# cd mysql/data
[root@iZ2873rjubzZ data]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
#设置mysql服务开机自动启动
[root@iZ2873rjubzZ mysql]# cp support-files/mysql.server /etc/init.d/mysql [root@iZ2873rjubzZ mysql]# chkconfig mysql on [root@iZ2873rjubzZ mysql]# service mysql start Starting MySQL. SUCCESS! [root@iZ2873rjubzZ mysql]#
[root@iZ2873rjubzZ mysql]# vim /etc/profile #修改环境变量 使得可以使用mysql命令 PATH添加/usr/local/mysql/bin [root@iZ2873rjubzZ mysql]# source /etc/profile #使得配置文件生效 [root@iZ2873rjubzZ mysql]# mysql -uroot #使用root(这时没有密码)登录 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.21 Source distribution Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql>
mysql> SET PASSWORD = PASSWORD(‘123456‘); #修改root用户的密码 mysql> GRANT ALL PRIVILEGES ON *.* TO root@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION; #root用户使用密码‘passwprd‘远程登录
标签:
原文地址:http://www.cnblogs.com/yyh19890221/p/4185035.html