MySQL第01课- CentOS + 单实例MySql编译安装总结

Posted micfox

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL第01课- CentOS + 单实例MySql编译安装总结相关的知识,希望对你有一定的参考价值。

2016年2月,从oracle转向mysql ,碰上几个坑,特此记录

总结

1、注意环境变量、配置文件,操作过程不能出错

2、相比rpm方式安装,编译安装方式可以指定安装路径,再说安装是简单活,将来安装最新版数据库,会看文档,学里面的知识更重要

3、系统管理员操作数据库一定要小心,重要操作应三思而后行

-----------------------------------------

1、注意:第一步要检查是否有安装过mysql,有的话要干掉,否则最后启动服务不成功

[[email protected] ~]# rpm -qa|grep mysql
 mysql-libs-5.1.73-5.el6_6.x86_64    
干掉之前安装的包 [[email protected]
~]# rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64

 2、写成sh文件,放到操作系统上。执行,可以出去喝茶回来看结果

cd /tools/
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
#CMake has bootstrapped. Now run gmake.
gmake
gmake install
cd ../
#依赖包
yum install ncurses-devel -y
#创建用户和组
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
mkdir -p /application/mysql-5.5.32/data
mkdir -p /application/mysql-5.5.32/tmp
#解压编译MySQL
cd /tools/
tar zxf mysql-5.5.32.tar.gz 
cd mysql-5.5.32
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 -DMYSQL_DATADIR=/application/mysql-5.5.32/data -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/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
make
#[100%] Built target my_safe_process
make install
ln -s /application/mysql-5.5.32/ /application/mysql
chown -R mysql:mysql /application/mysql/
chmod -R 1777 /tmp/
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

 ------------------ 会出现如下

Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/application/mysql//bin/mysqladmin -u root password ‘new-password‘
/application/mysql//bin/mysqladmin -u root -h fox password ‘new-password‘

Alternatively you can run:
/application/mysql//bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl

Please report any problems with the /application/mysql//scripts/mysqlbug script!

表示安装正常!

3、配置my.cnf文件,环境变量,启动服务

[[email protected] tools]# cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
[[email protected] tools]# echo export PATH=/application/mysql/bin:$PATH >> /etc/profile
[[email protected] tools]# source /etc/profile
[[email protected] tools]# /bin/cp mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld 
[[email protected] tools]# chmod +x /etc/init.d/mysqld 
[[email protected] tools]# /etc/init.d/mysqld start
Starting MySQL... [ OK ]
[[email protected] tools]# netstat -lnutp|grep 3306 
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 26343/mysqld 

4、进入MySQL数据库 

[[email protected] tools]# mysql


以上是关于MySQL第01课- CentOS + 单实例MySql编译安装总结的主要内容,如果未能解决你的问题,请参考以下文章

CentOS6 MySql5.5.53编译安装+多实例实战

centos7mysql5.6.30单机多实例配置主主复制

centos6.5 安装mysql5.6单实例和多实例(单配置文件)

MySQL的单实例和多实例安装

Oracle_lhr_CentOS 7.3 ECS上搭建RAC 18c+单实例DG+EMCC+DG

CentOS7.7下二进制部署MySQL多版本多实例实战