转载自
Mysql 5.5以后使用了CMake进行安装,参考与以前的区别请参考:
接上文。
1:下载:当前mysql版本到了5.6.17
wget
2:必要软件包
yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake bison bison-devel
# 新增用户组
groupadd mysql
# 新增用户
useradd mysql -g mysql
# 新建数据库执行文件目录
mkdir -p /usr/local/mysql
# 新建数据库数据文件目录
mkdir -p /db/mysql/data
# 修改目录拥有者
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /db/mysql/data
chown -R mysql:mysql /usr/local/mysql/.
chown -R mysql:mysql /db/mysql/data/.
# 编辑PATH搜索路径
vi /etc/profile添加如下两行: PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATHexport PATH# 生效PATH搜索路径
source /etc/profile
# 安装编译源码所需的工具和库
yum -y install wget gcc-c++ ncurses-devel cmake make perl# 进入源码压缩包下载目录
cd /usr/src# 下载源码压缩包
wget# 解压缩源码包
tar -zxv -f mysql-5.6.17.tar.gz# 进入解压缩源码目录
cd mysql-5.6.17
# 编译并安装
复制代码
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-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 \-DWITH_READLINE=1 \-DENABLED_LOCAL_INFILE=1 \-DMYSQL_DATADIR=/db/mysql/data \-DMYSQL_USER=mysql \-DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1(出现Googlemock was not found. 加上)-DWITH_DEBUG=0
make && make install
红色部分表示禁用Debug模式。
复制代码# 复制配置文件cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf# 进入安装路径
cd /usr/local/mysql# 执行配置脚本
scripts/mysql_install_db --user=mysql --datadir=/db/mysql/data# 复制服务启动脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql# 启动MySQL服务
service mysql start# 设置开机自动启动服务
chkconfig mysql on#添加系统变量
echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:\$PATH" >> /etc/profile
echo "export PATH" >> /etc/profilesource /etc/profile>>>>>>>>>>>>>>>完成
如果发生如下错误:
[root@rekfan mysql]# service mysql restart
MySQL server PID file could not be found![失败]Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/rekfan.pid).[失败]黄海的问题解决办法是:
killall命令
killall命令杀死同一进程组内的所有进程。其允许指定要终止的进程的名称,而非PID。 # killall mysqld 再次查看mysqld进程: ps -ef|grep mysqld 没有了!世界清静了。运行 mysql
然后进入mysql> 提示符后,输入status;
查看安装情况。
复制代码
mysql> status;--------------mysql Ver 14.14 Distrib 5.6.10, for Linux (x86_64) using EditLine wrapperConnection id: 1
Current database:Current user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.6.10 Source distributionProtocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: latin1Conn. characterset: latin1UNIX socket: /tmp/mysql.sockUptime: 7 secThreads: 1 Questions: 5 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.714
--------------复制代码 #表名全部为小写,避免出现大小写敏感vi /etc/my.cnf 添加如下内容,解决大小写表名敏感问题。
lower_case_table_names=1
修改MySQL的root用户的密码以及打开远程连接
mysql
mysql> use mysql;
复制代码
mysql> desc user;mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力
mysql> update user set Password = password('123456') where User='root'; //设置root用户密码mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit
复制代码
附自动安装脚本如下:
vi installmysql.sh
chmod 777 installmysql.sh
./installmysql.sh
内容如下:
复制代码
yum -y install wget gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake perl bison bison-develgroupadd mysql
useradd mysql -g mysqlmkdir -p /usr/local/mysqlmkdir -p /db/mysql/datachown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /db/mysql/datachown -R mysql:mysql /usr/local/mysql/.chown -R mysql:mysql /db/mysql/data/.echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:\$PATH" >> /etc/profile
echo "export PATH" >> /etc/profilesource /etc/profile
cd /usr/software/
#下载mysql源码包wget tar -zxvf mysql-5.6.17.tar.gzcd /usr/software/mysql-5.6.17cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -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 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/db/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306make && make installcp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
cd /usr/local/mysqlscripts/mysql_install_db --user=mysql --datadir=/db/mysql/datacp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqlecho "lower_case_table_names=1" >> /etc/my.cnf
service mysql start
chkconfig mysql onmysqladmin -u root password 'dsideal'
service iptables stop
chkconfig iptables offsed -i 's#SELINUX=enforcing#SELINUX=disabled#'g /etc/sysconfig/selinux