基于二进制通用格式安装mysql-5.5.52
环境介绍:
Linux主机:centos6.8
mysql二进制格式包:mysql-5.5.52-linux2.6-x86_64.tar.gz
1、解压包到特定目录
[[email protected] ~]# tar xf mysql-5.5.52-linux2.6-x86_64.tar.gz -C /usr/local/
2、创建软链接
[[email protected] ~]# ln -sv /usr/local/mysql-5.5.52-linux2.6-x86_64/ /usr/local/mysql `/usr/local/mysql‘ -> `/usr/local/mysql-5.5.52-linux2.6-x86_64/‘
3、进入该目录、查看安装帮助,开始安装
[[email protected] ~]# cd /usr/local/mysql [[email protected] mysql]# cat INSTALL-BINARY //根据提示到指定网站查看帮助
[[email protected] mysql]# groupadd mysql [[email protected] mysql]# useradd -r -g mysql -s /bin/false mysql //原来存在则不需要执行 [[email protected] mysql]# chown -R mysql . [[email protected] mysql]# chgrp -R mysql . [[email protected] mysql]# ./scripts/mysql_install_db --help //查看选项 我们这里不使用它默认的数据库存放位置 [[email protected] mysql]# mkdir -pv /mysql/data/ //数据库文件最好放在 硬raid 的 LVM 上 [[email protected] mysql]# chown mysql:mysql /mysql/data/ [[email protected] mysql]# ll -d /mysql/data/ drwxr-xr-x. 2 mysql mysql 4096 Sep 16 21:44 /mysql/data/ [[email protected] mysql]# ./scripts/mysql_install_db --datadir=/mysql/data/ --user=mysql [[email protected] mysql]# ls /mysql/data/ mysql performance_schema test //数据库初始化时生成的三个系统的数据库文件
[[email protected] mysql]# cp support-files/my-medium.cnf /etc/my.cnf cp: overwrite `/etc/my.cnf‘? y //不使用系统上默认安装的mysql数据库则可以覆盖原来的配置文件 [[email protected] mysql]# vim /etc/my.cnf
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld.server [[email protected] mysql]# chkconfig --add mysqld.server
4、测试启动
[[email protected] mysql]# service mysqld.server start Starting MySQL.. [ OK ] [[email protected] mysql]# ss -tln LISTEN 0 50 *:3306
启动成功
此时数据库目录下会多出许多的文件或目录
5、最后的配置
导出man文档
[[email protected] ~]# vim /etc/man.config MANPATH /usr/local/mysql/man --> 添加该行
导出头文件
[[email protected] ~]# ln -sv /usr/local/mysql/include/ /usr/include/mysql `/usr/include/mysql‘ -> `/usr/local/mysql/include/‘
导出库文件
[[email protected] ~]# vim /etc/ld.so.conf.d/mysql.conf /usr/local/mysql/lib
重新加载系统库文件
[[email protected] lib]# ldconfig -v
导出二进制程序路径
[[email protected] ~]# vim /etc/profile.d/mysql.sh [[email protected] ~]# . /etc/profile.d/mysql.sh
OK
时间: 2024-11-04 16:54:20