[Deepin 15] 编译安装 MySQL-5.6.35
在 Ubuntu 下,先前一直是 二进制包解压安装,详情参考:
http://www.cnblogs.com/52php/p/5680906.html
现改为 源码编译安装:
#!/bin/bash # 安装 依赖库 sudo apt-get -y install make cmake gcc g++ bison openssl libssl-dev libncurses5-dev # 创建 数据 文件夹 sudo mv /fiisoo/mysql /fiisoo/mysql.$(date "+%Y-%m-%d.%s") sudo mkdir -pv /fiisoo/mysql/conf sudo mkdir -pv /fiisoo/mysql/log sudo mkdir -pv /fiisoo/mysql/tmp sudo mkdir -pv /fiisoo/mysql/data # 创建 mysql 用户及用户组(直接用当前登录账号:52php:52php) #groupadd mysql #useradd -g mysql -s /usr/sbin/nologin mysql # 不让 mysql 用户直接登录 # 解压 mysql-5.6.35 cd /usr/local/src/ubuntu-sdk/source2/mysql sudo rm -rf ./mysql-5.6.35 sudo tar -xzvf ./mysql-5.6.35.tar.gz cd ./mysql-5.6.35 sudo mkdir -pv /usr/local/mysql/mysql-5.6 # 设置 权限 sudo chown -R 52php:52php ../mysql-5.6.35 sudo chown -R 52php:52php /usr/local/mysql # 生成 配置 sudo cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/mysql-5.6 \ -DMYSQL_DATADIR=/fiisoo/mysql/data \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_unicode_ci \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLED_LOCAL_INFILE=1 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_DEBUG=0 # 安装 sudo make sudo make install # 复制 配置文件 #cp ./support-files/my-medium.cnf /etc/my.cnf sudo mv /etc/my.cnf /etc/my.cnf.$(date "+%Y-%m-%d.%s") sudo mv /fiisoo/mysql/conf/my.cnf /fiisoo/mysql/conf/my.cnf.$(date "+%Y-%m-%d.%s") sudo \cp -rf /usr/local/src/ubuntu-sdk/config/mysql-5.6/my.cnf /fiisoo/mysql/conf/ sudo ln -s /fiisoo/mysql/conf/my.cnf /etc/my.cnf # 设置 权限 sudo chmod -R 755 /usr/local/mysql/mysql-5.6 sudo chown -R 52php:52php /usr/local/mysql/mysql-5.6 sudo chown -R 52php:52php /fiisoo/mysql # 设置 开机自动启动 # cp ./support-files/mysql.server /etc/init.d/mysqld sudo \cp -rf /usr/local/src/ubuntu-sdk/config/mysql-5.6/mysqld.init /etc/init.d/mysqld sudo update-rc.d mysqld defaults sudo service mysqld start #启动mysql # 添加 mysql 的软链接以适应 init 脚本 sudo ln -sv /usr/local/mysql/mysql-5.6/bin/mysql /usr/sbin/mysql sudo ln -sv /usr/local/mysql/mysql-5.6/bin/mysqladmin /usr/sbin/mysqladmin sudo ln -sv /usr/local/mysql/mysql-5.6/bin/mysqldump /usr/sbin/mysqldump # 初始化 数据库 sudo /usr/local/mysql/mysql-5.6/scripts/mysql_install_db \ --user=52php \ --basedir=/usr/local/mysql/mysql-5.6 \ --datadir=/fiisoo/mysql/data # 启动 mysql sudo killall mysqld sudo service mysqld start # 修改 root 密码 # 注意:先输入旧密码(默认为空密码),然后让你输入新密码 # /usr/local/mysql/mysql-5.6/bin/mysqladmin -u root -p password # 把端口 3306 添加到防火墙 # vim /etc/sysconfig/iptables # service iptables restart
参考: