groupadd mysql 添加使用者組
useradd mysql -s /sbin/nologin -g mysql -M 添加使用者
mv mysql-5.5.54-linux2.6-x86_64.tar.gz /home/ye/software/ 下載下傳軟體到軟體包
cd /home/ye/software/
tar -xf mysql-5.5.54-linux2.6-x86_64.tar.gz #解壓mysql軟體
cd mysql-5.5.54-linux2.6-x86_64
mv /home/ye/software/mysql-5.5.54-linux2.6-x86_64/ /application/mysql-5.5.54/ 移動軟體包到安裝路徑内
cd /application/mysql-5.5.54/
ln -s /application/mysql-5.5.54/ /application/mysql #建立軟連接配接
ls -l /application/mysql/support-files/*.cnf
cp /application/mysql/support-files/my-small.cnf /etc/my.cnf 配置配置檔案
mkdir -p /application/mysql/data 建立data資料目錄
chown -R mysql.mysql /application/mysql/ #修改目錄權限
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql -- datadir=/application/mysql/data --user=mysql #初始化mysql
tree /application/mysql/data/ #檢視
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld 添權重限
ll /etc/init.d/mysqld
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld #修改配置檔案内預設的程式執行路徑
/etc/init.d/mysqld start 啟動mysql
/application/mysql/bin/mysqld_safe --user=mysql& #另一種方式啟動MYSQL
netstat -lntup 檢視3306端口是否啟動
chkconfig --add mysqld 添加服務
chkconfig mysqld on 設定mysql服務開機預設啟動
chkconfig --list mysqld 檢視服務狀态
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile #更改mysql指令的全局環境變量;另一種方法為把/application/mysql/bin/下面的指令拷貝到已經是全局系統指令的路徑/usr/local/sbin下#
source /etc/profile
echo $PATH
mysql 測試登入,預設沒有密碼
mysqladmin -u root password 'ye123456' 設定root密碼
設定完成root密碼後需要對MYSQL進行安全配置
注:如遇到提示can't crate file '/tmp/*' 時需要對此目錄添權重限chmod -R 1777 /tmp/
轉載于:https://www.cnblogs.com/dianzixiaoming/p/6245605.html