来源:/littlehb/archive//04/02/2995007.html
Mysql 5.5以后使用了CMake进行安装,参考与以前的区别请参考:
/kelly859/archive//09/04/387005.html
接上文。
1:必要软件包
yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake
# 新增用户组
groupaddmysql
# 新增用户
useradd mysql-gmysql
# 新建数据库执行文件目录
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:$PATH
export PATH
# 生效PATH搜索路径
source /etc/profile
# 安装编译源码所需的工具和库
yum -y install wget gcc-c++ ncurses-devel cmake make perl
# 进入源码压缩包下载目录
cd /usr/src
# 下载源码压缩包
wget /get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from//
# 解压缩源码包
tar -zxv -f mysql-5.6.10.tar.gz
# 进入解压缩源码目录
cd mysql-5.6.10
# 编译并安装
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_SPHINX_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 \-DWITH_DEBUG=0make && make install红色部分表示禁用Debug模式。
# 复制配置文件
cp /usr/local/mysql/support-files/my-f /etc/f
# 进入安装路径
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
>>>>>>>>>>>>>>>完成
如果发生如下错误:
[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:1Current 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: latin1Dbcharacterset: 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/f 添加如下内容,解决大小写表名敏感问题。
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.shchmod 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 perlgroupadd mysqluseradd mysql -g mysqlmkdir -p /usr/local/mysqlmkdir -p /db/mysql/datachown -R mysql:mysql /usr/local/mysqlchown -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/profileecho "export PATH" >> /etc/profilesource /etc/profilecd /usr/software/#下载mysql源码包#wget /get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from//tar -zxvf mysql-5.6.10.tar.gzcd /usr/software/mysql-5.6.10cmake -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-f /etc/fcd /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/fservice mysql startchkconfig mysql onmysqladmin -u root password 'dsideal'service iptables stopchkconfig iptables offsed -i 's#SELINUX=enforcing#SELINUX=disabled#'g /etc/sysconfig/selinux
如果觉得《单机运行环境搭建之 --CentOS-6.4安装MySQL 5.6.10并修改MySQL的root用户密码》对你有帮助,请点赞、收藏,并留下你的观点哦!