[第二章]MySQL5.6.40源码安装

 黑渐神|he-jason.com   2018-11-22 15:22   5,284 人阅读  [第二章]MySQL5.6.40源码安装已关闭评论

编译环境

#安装编译依赖环境
yum install -y gcc gcc-c++ automake autoconf cmake
yum -y install cmake bison-devel ncurses-devel libaio-devel
上传并解压mysql-5.6.40.tar.gz
mv mysql-5.6.40 /usr/local
ln -s /usr/local/mysql-5.6.40 /usr/local/mysql #建立软链接

编译配置

#cmake mysql编译前配置参数
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.40 -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

编译安装

make && make install #编译并安装

基本配置

#配置数据文件夹
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#复制Mysql配置文件my.cnf
cp support-files/my-default.cnf /etc/my.cnf
#把启动文件加入init.d下
cp support-files/mysql.server /etc/init.d/mysqld
#定义mysql/bin的全局环境
echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile
source /etc/profile #使环境生效

服务管理

/etc/init.d/mysqld start        #开启mysql服务
/etc/init.d/mysqld stop         #关闭mysql服务
/etc/init.d/mysqld status       #查看mysql服务状态
/etc/init.d/mysqld restart      #重启mysql服务
/etc/init.d/mysqld reload       #重载mysql服务
/etc/init.d/mysqld force-reload #强制重载mysql服务
mysql

sock启动配置

socket=/tmp/mysql.sock      #配置启动的mysql.sock文件位置
mysql -S /tmp/mysql.sock    #指定sock启动

my.cnf配置

show variables; #查看可配置变量

使用systemctl管理mysqld

vim /etc/systemd/system/mysqld.service #在此位置编写此脚本但可使用systemctl管理mysqld
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql

# Start main service
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

# Sets open_files_limit
LimitNOFILE = 5000

先重载一下systemctl配置

systemctl daemon-reload

systemctl 管理mysql命令

    systemctl start mysqld
    systemctl status mysqld
    systemctl stop mysqld
    …………
本文地址:https://www.he-jason.com/dbskill/mysql/446.html
版权声明:本文为原创文章,版权归 黑渐神|he-jason.com 所有,欢迎分享本文,转载请保留出处!
双11拉新分百万红包

评论已关闭!