linux虚拟环境上的mysql安装步骤

linux虚拟环境上的mysql安装步骤,第1张

概述linux虚拟环境上的mysql安装步骤 一、Mysql的源码安装: 1、下载mysql安装包 mysql官网: https://www.mysql.com/ DOWNLOADS >>>Archives >> MySQL Community Server 版本选择潜规则: MySQL5.6: 1.选择GA 6-12个月 2.小版本号为偶数版 MySQL5.7 1.选择GA 6-12个月 2.小版本

linux虚拟环境上的MysqL安装步骤

一、MysqL的源码安装:

1、下载MysqL安装包

MysqL官网: https://www.mysql.com/ DOWNLOADS >>>Archives >> MysqL Community Server

版本选择潜规则:

MysqL5.6: 1.选择GA 6-12个月 2.小版本号为偶数版

MysqL5.7 1.选择GA 6-12个月 2.小版本号为偶数版 3.MysqL5.7.17以上版本 MGR

选择版本 5.6.40 operating system:Source Code 点击下载

2、将下载的源码压缩文件传到虚拟机上 直接拖(虚拟机需要先安装lrzsz:yum install -y lrzsz)

3、解压: [[email protected] ~]# tar xf mysql-5.6.40.tar.gz

4、进入到解压的目录里面:

[[email protected] ~]# cd mysql-5.6.40 [[email protected] mysql-5.6.40]# ll

5、生成编译文件:

[[email protected] mysql-5.6.40]#
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.40 \
-DMysqL_DATADIR=/usr/local/mysql-5.6.40/data \
-DMysqL_UNIX_ADDR=/usr/local/mysql-5.6.40/tmp/MysqL.sock \
-DDEFAulT_CHARSET=utf8 \
-DDEFAulT_ColLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHolE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZliB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INfile=1 \
-DWITH_EMbedDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0
?
# 意思解析:
[[email protected] mysql-5.6.36]#
#程序存放位置
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.38 \
#数据存放位置
-DMysqL_DATADIR=/application/mysql-5.6.38/data \
#socket文件存放位置
-DMysqL_UNIX_ADDR=/application/mysql-5.6.38/tmp/MysqL.sock \
#使用utf8字符集
-DDEFAulT_CHARSET=utf8 \
#校验规则
-DDEFAulT_ColLATION=utf8_general_ci \
#使用其他额外的字符集
-DWITH_EXTRA_CHARSETS=all \
#支持的存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHolE_STORAGE_ENGINE=1 \
#禁用的存储引擎
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
#启用zlib库支持(zib、gzib相关)
-DWITH_ZliB=bundled \
#启用SSL库支持(安全套接层)
-DWITH_SSL=bundled \
#启用本地数据导入支持
-DENABLED_LOCAL_INfile=1 \
#编译嵌入式服务器支持
-DWITH_EMbedDED_SERVER=1 \
# MysqL5.6支持了Google的c++mock框架了,允许下载,否则会安装报错。
-DENABLE_DOWNLOADS=1 \
#禁用deBUG(默认为禁用)
-DWITH_DEBUG=0
#编译

6、编译:[[email protected] mysql-5.6.40]#make

7、安装:[[email protected] mysql-5.6.40]#make install

8、创建MysqL系统用户:[[email protected] mysql-5.6.40]# useradd MysqL -s /sbin/nologin -M

9、进入配置文件及脚本目录:[[email protected] mysql-5.6.40]# cd support-files/

10、拷贝配置文件到etc [[email protected] support-files]# cp my-default.cnf /etc/my.cnf cp: overwrite ‘/etc/my.cnf’? y

11、拷贝启动脚本 [[email protected] support-files]# cp MysqL.server /etc/init.d/MysqLd

12、进入初始化目录 [[email protected] mysql-5.6.40]# cd /usr/local/mysql-5.6.40/scripts/

13、初始化数据库 [[email protected] scripts]# ./MysqL_install_db --user=MysqL --basedir=/usr/local/mysql-5.6.40 --datadir=/usr/local/mysql-5.6.40/data

14、做软连接 [[email protected] scripts]# ln -s /usr/local/mysql-5.6.40 /usr/local/MysqL

15、启动MysqL [[email protected] scripts]# /etc/init.d/MysqLd start

附:此处有可能做完软连接后还是会出现报错,

此时可以通过: [[email protected] scripts]# tail -100 /usr/local/MysqL/data/db02.err 命令来查看错误信息error

此处为编译时给的sock的文件所在位置 -DMysqL_UNIX_ADDR=/usr/local/mysql-5.6.40/tmp/MysqL.sock 但是系统中没有此文件夹,所以解决办法为创建此文件: [[email protected] scripts]# mkdir /usr/local/mysql-5.6.40/tmp

Starting MysqL.Logging to ‘/usr/local/MysqL/data/db02.err‘. . SUCCESS!

16、添加环境变量 [[email protected] scripts]# vim /etc/profile export PATH="/usr/local/MysqL/bin:$PATH" 添加到最后一行

17、加载环境变量 [[email protected] scripts]# source /etc/profile

18、授权 [[email protected] scripts]# chown -R MysqL.MysqL /usr/local/MysqL*

19、连接MysqL [[email protected] scripts]# MysqL

20、设置MysqL密码 [[email protected] scripts]# MysqLadmin -uroot -p password 123

21、连接MysqL [[email protected] scripts]# MysqL -uroot -p123

二、二进制安装

1、下载MysqL安装包

MysqL官网: https://www.mysql.com/    DOWNLOADS >>>Archives >> MysqL Community Server

版本选择潜规则:

MysqL5.6: 1.选择GA 6-12个月 2.小版本号为偶数版

MysqL5.7 1.选择GA 6-12个月 2.小版本号为偶数版 3.MysqL5.7.17以上版本 MGR

选择版本 5.6.40 operating system:linux-Generic 点击下载

2、将下载的源码压缩文件传到虚拟机上 直接拖(虚拟机需要先安装lrzsz:yum install -y lrzsz)

3、解压:[[email protected] ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz

4、将解压的文件移动到usr/local 目录下: [[email protected] ~]# mv mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql-5.6.40

5、进入到MysqL目录下:[[email protected] ~]# cd /usr/local/mysql-5.6.40/

6.创建MysqL系统用户 [[email protected] mysql-5.6.40]# useradd MysqL -s /sbin/nologin -M

7.进入配置文件及脚本目录 [[email protected] mysql-5.6.40]# cd support-files/

8.拷贝配置文件到etc [[email protected] support-files]# cp my-default.cnf /etc/my.cnf cp: overwrite ‘/etc/my.cnf’? y

9.拷贝启动脚本 [[email protected] support-files]# cp MysqL.server /etc/init.d/MysqLd

10.进入初始化目录 [[email protected] mysql-5.6.40]# cd /usr/local/mysql-5.6.40/scripts/

11.初始化数据库 [[email protected] scripts]# ./MysqL_install_db --user=MysqL --basedir=/usr/local/mysql-5.6.40 --datadir=/usr/local/mysql-5.6.40/data

12.做软连接 [[email protected] scripts]# ln -s /usr/local/mysql-5.6.40 /usr/local/MysqL

13.启动MysqL [[email protected] scripts]# /etc/init.d/MysqLd start

Starting MysqL.Logging to ‘/usr/local/MysqL/data/db02.err‘. . SUCCESS!

14.添加环境变量 [[email protected] scripts]# vim /etc/profile export PATH="/usr/local/MysqL/bin:$PATH"

15.加载环境变量 [[email protected] scripts]# source /etc/profile

16.授权 [[email protected] scripts]# chown -R MysqL.MysqL /usr/local/MysqL*

17.连接MysqL [[email protected] scripts]# MysqL

18.设置MysqL密码 [[email protected] scripts]# MysqLadmin -uroot -p password 123

19.连接MysqL [[email protected] scripts]# MysqL -uroot -p123

总结

以上是内存溢出为你收集整理的linux虚拟环境上的mysql安装步骤全部内容,希望文章能够帮你解决linux虚拟环境上的mysql安装步骤所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1027060.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存