一、下载MySQL5.6.38安装包
下载地址:https://www.mysql.com/downloads/ 打开网站之后选择Archives
然后再选择开源版本
选择我们要下载的版本:
https://downloads.mysql.com/archives/community/
二、编译安装MySQL5.6.38
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
创建系统帐号
# groupadd -r mysql
# useradd -r -g mysql -s /sbin/nologin mysql
关闭SELinux
# setenforce 0
# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
安装依赖包
# yum install ncurses-devel libaio-devel -y
# yum install cmake gcc gcc-c++ make autoconf -y
上面如果没有下载安装包,可直接wget下载
# wget https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.38.tar.gz
# tar xf mysql-5.6.38.tar.gz
# cd mysql-5.6.38/
# 进行编译安装
[ ~/mysql-5.6.38]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.38
# 指定安装目录
-DMYSQL_DATADIR=/usr/local/mysql-5.6.38/data # 指定数据目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.6.38/mysql.sock # 指定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_SSL=bundled # 编译其它功能SSL、ZLIB等
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0 -DSYSCONFDIR=/etc
[ ~/mysql-5.6.38]# make && make install # 编译并安装数据库
# 做软链接并给MySQL目录授权
# ln -s /usr/local/mysql-5.6.38/ /usr/local/mysql
# chown -R mysql.mysql /usr/local/mysql
mysql-5.7.35的编译参数
https://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz # 浏览器拷贝网址直接下载,然后再上传到服务器
tar xf boost_1_59_0.tar.gz -C /usr/local/
ln -s /usr/local/boost_1_59_0 /usr/local/boost
cmake . -DCMAKE_INSTALL_PREFIX=/data/app/mysql-5.7.35 -DMYSQL_DATADIR=/data/app/mysql-5.7.35/data -DMYSQL_UNIX_ADDR=/data/app/mysql-5.7.35/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_SSL=system -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_EMBEDDED_SERVER=1 -DENABLE_DOWNLOADS=1 -DWITH_DEBUG=0 -DSYSCONFDIR=/etc -DWITH_BOOST=/usr/local/boost
make && make install
# 做软链接并给MySQL目录授权
ln -s /data/app/mysql-5.7.35 /data/app/mysql
chown -R mysql.mysql /data/app/mysql-5.7.35/
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
touch /data/log/mysql.log
chown mysql.mysql /data/log/mysql.log
/data/app/mysql/bin/mysqld --initialize-insecure --basedir=/data/app/mysql --datadir=/data/app/mysql/data --user=mysql
cat > /etc/my.cnf << EOF
[mysqld]
server_id=1
port=3306
basedir=/data/app/mysql
datadir=/data/app/mysql/data
socket=/data/app/mysql/mysql.sock
log_bin=/data/app/mysql/mysql-bin
log_error=/data/log/mysql.log
character-set-server=utf8
[client]
socket=/data/app/mysql/mysql.sock
EOF
三、初始化数据目录
# MySQL 5.6初始化数据库的命令:
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data -user=mysql
# MySQL 5.7初始化数据库的命令:
/data/app/mysql/bin/mysqld --initialize-insecure --basedir=/data/app/mysql --datadir=/data/app/mysql/data --user=mysql
四、拷贝启动服务的脚本
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chmod 700 /etc/init.d/mysqld
五、改环境变量
# echo 'PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile
# source /etc/profile
六、改配置文件,并启动数据库
# vim /etc/my.cnf
[mysqld]
server_id=1
port=3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
log_bin=/usr/local/mysql/mysql-bin
log_error=/var/log/mysql.log
character-set-server=utf8
[client]
socket=/usr/local/mysql/mysql.sock
# /etc/init.d/mysqld start
七、设置数据库密码并清空MySQL不安全帐号
# mysqladmin -u root password 123456
# mysql -uroot -p123456
# 清除不安全的用户,先查询用户名为空和没有密码的
> select user,password,host from mysql.user;
> drop user root@'127.0.0.1';
> drop user ''@'localhost';
版权属于: 三三世界-百宝箱
本文链接: http://33f.net/build/centos7_install_mysql5-6.html
本文最后更新于2021年12月24日 ,已超过1093天没有更新,若内容或图片失效,请留言反馈。
本文允许转载,但请在转载时请以超链接或其它形式标明文章出处
@Doug Shume it's ok for me , you can post here.
Saved as a favorite, I like your website!
If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.
Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!
Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.
Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.
zh.us.to 有效
kms.03k.org 有效
kms.chinancce.com
kms.shuax.com 有效
kms.dwhd.org 有效
kms.luody.info 有效
kms.digiboy.ir 有效
kms.lotro.cc 有效
www.zgbs.cc 有效
cy2617.jios.org 有效
@ 权限问题,试试sudo 再加命令。
你好提示Permission denied 怎么办啊