精通RHEL7编译安装mysql-5.5.32

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了精通RHEL7编译安装mysql-5.5.32相关的知识,希望对你有一定的参考价值。

准备环境
安装mysql依赖包
yum install -y ncurses-devel
[[email protected] ~]# cd tools/
[[email protected] tools]# ls
cmake-2.8.8.tar.gz mysql-5.5.32.tar.gz
安装cmake
[[email protected] tools]# tar -xf cmake-2.8.8.tar.gz
[[email protected] tools]# cd cmake-2.8.8/
[[email protected] cmake-2.8.8]# ./configure
……
-- Configuring done
-- Generating done
-- Build files have been written to: /root/tools/cmake-2.8.8
---------------------------------------------
CMake has bootstrapped. Now run gmake.
[[email protected] cmake-2.8.8]# gmake
[[email protected] cmake-2.8.8]# gmake install
[[email protected] ~]# cd tools/
[[email protected] tools]# tar -xf mysql-5.5.32.tar.gz
[[email protected] tools]# cd mysql-5.5.32/
[[email protected] mysql-5.5.32]# cat install-mysql5.5.32.sh
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii
-DENABLED_LOCAL_INFILE=ON
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
-DWITH_FAST_MUTEXES=1
-DWITH_ZLIB=bundled
-DENABLED_LOCAL_INFILE=1
-DWITH_READLINE=1
-DWITH_EMBEDDED_SERVER=1
-DWITH_DEBUG=0
[[email protected] mysql-5.5.32]# bash install-mysql5.5.32.sh
[[email protected] mysql-5.5.32]# make -j 4 && make install
初始化配置
[[email protected] ~]# useradd -M -s /sbin/nologin mysql
[[email protected] ~]# cd tools/mysql-5.5.32/
[[email protected] mysql-5.5.32]# cp support-files/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
添加启动脚本到系统中
[[email protected] mysql-5.5.32]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[[email protected] mysql-5.5.32]# chmod 750 /etc/rc.d/init.d/mysqld
环境变量配置
[[email protected] ~]# source /etc/profile
[[email protected] ~]# tail -n 1 /etc/profile
PATH=/usr/local/mysql/bin/:$PATH
初始化数据库
[[email protected] ~]# chown -R mysql.mysql /usr/local/mysql
[[email protected] ~]# cd /usr/local/mysql/scripts/
[[email protected] scripts]# ./mysql_install_db
> --basedir=/usr/local/mysql
> --datadir=/usr/local/mysql/data
> --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
启动服务
[[email protected] ~]# service mysqld start
Starting MySQL... SUCCESS!
[[email protected] ~]# netstat -anutp | grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 28170/mysqld
设置密码(这里使用自带的安全脚本)
[[email protected] ~]# mysql_secure_installation
……
Set root password? [Y/n]
New password: 1
Re-enter new password: 1
Password updated successfully!
……
查看授权表
[[email protected] ~]# mysql -uroot -p1
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
+------+-----------+
3 rows in set (0.01 sec)
删除多余的授权数据项
mysql> delete from mysql.user where host=‘::1‘;
Query OK, 1 row affected (0.00 sec)
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
觉得本文章不错的可以分享给您的朋友或订阅我,后期会分享更多的Linux技术文章

以上是关于精通RHEL7编译安装mysql-5.5.32的主要内容,如果未能解决你的问题,请参考以下文章

MySQL 5.5.32 编译安装

MySQL 5.5.32 编译安装

cmake源码编译安装mysql-5.5.32:多实例遇到的坑

cmake源码编译安装mysql-5.5.32:多实例遇到的坑

Mysql编译安装

CentOS6.7通过cmake编译安装mysql5.5.32