linux虚拟环境上的mysql安装步骤
一、Mysql的源码安装: 1、下载mysql安装包 mysql官网: https://www.mysql.com/ DOWNLOADS >>>Archives >> MySQL Community Server 版本选择潜规则:
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]#
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |