#卸載mysql /etc/init.d/mysqld stop &> /dev/null killall mysqld &> /dev/null sudo rm -rf /mengdi/server/mysql &> /dev/null sudo rm -rf /mengdi/server/mysql-* &> /dev/null sudo rm -rf /mengdi/log/mysql &> /dev/null sudo rm -rf /etc/my.cnf sudo rm -f /etc/init.d/mysqld 更改環境變量
准備工作1,創建環境統一目錄 sudo mkdir /mengdi cd /mengdi sudo mkdir server sudo mkdir -p log/mysql
准備工作2,創建mysql用戶及組 groupadd mysql useradd -g mysql -s /sbin/nologin mysql
准備工作3,安裝依賴 apt-get -y update apt-get -y autoremove mysql-server apt-get -y install unzip build-essential libncurses5-dev libfreetype6-dev libxml2-dev libssl-dev libcurl4-openssl-dev libjpeg62-dev libpng12-dev libfreetype6-dev libsasl2-dev libpcre3-dev autoconf libperl-dev libtool libaio*
著手干
cd /usr/src 下載 mysql-5.6.21 通用二進制文件 sudo wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz 也可 sudo wget -P /usr/src http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz cd /usr/src sudo -xzf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz #解壓 cd /mengdi/server sudo cp -r /usr/src/mysql-5.6.21-linux-glibc2.5-x86_64 ./ #拷貝文件 sudo ln -s /mengdi/server/mysql-5.6.21-linux-glibc2.5-x86_64/ /mengdi/server/mysql sudo /mengdi/server/mysql/scripts/mysql_install_db --datadir=/mengdi/server/mysql/data/ --basedir=/mengdi/server/mysql --user=mysql #安裝 chown -R mysql:mysql /alidata/server/mysql/ #更改權限 chown -R mysql:mysql /alidata/server/mysql/data/ #更改權限 chown -R mysql:mysql /alidata/log/mysql/ #更改權限 sudo cp -f /mengdi/server/mysql/support-files/mysql.server /etc/init.d/mysqld #拷貝啟動文件 sudo sed -i 's/^basedir=$/basedir=\/mengdi\/server\/mysql/' /etc/init.d/mysqld #替換路徑 sudo sed -i 's/^datadir=$/datadir=\/mengdi\/server\/mysql\/data/' /etc/init.d/mysqld #替換路徑 sudo vim /etc/my.cnf #啟動時,未指定配置文件時,會用此文件 [client] port=3306 socket=/tmp/mysql.sock [mysqld] port=3306 socket=/tmp/mysql.sock skip-external-locking log-error=/mengdi/log/mysql/error.log key_buffer_size=16M max_allowed_packet=1M table_open_cache=64 sort_buffer_size=512K net_buffer_length=8K read_buffer_size=256K read_rnd_buffer_size=512K myisam_sort_buffer_size=8M log-bin=mysql-bin binlog_format=mixed server-id=1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqldump] quick max_allowed_packet=16M [mysql] no-auto-rehash [myisamchk] key_buffer_size=20M sort_buffer_size=20M read_buffer=2M write_buffer=2M [mysqlhotcopy] interactive-timeout expire_logs_days=5 max_binlog_size=1000M
sudo chmod 755 /etc/init.d/mysqld sudo /etc/init.d/mysqld start #{start|stop|restart|reload|force-reload|status} ps -ef |grep mysqld export PATH=$PATH:/mengdi/server/mysql/bin
http://xxxxxx/Linuxjc/1135721.html TechArticle