mysql5.7靜默安裝

1.下載mysql

cd /opt
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
tar xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv  mysql-5.7.17-linux-glibc2.5-x86_64 mysql

2.路徑配置linux

basedir=/opt/mysql
datadir=/opt/mysql/data

2.新增mysql用戶sql

groupadd mysql
useradd -r -g mysql mysql

cd /opt
mkdir /opt/mysql/data
chown -R mysql:mysql mysql

//mysql初始化
./bin/mysql_install_db --user=mysql --basedir=/opt/mysql/ --datadir=/opt/mysql/data/

-- 如遇錯誤--
/opt/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

yum install libaio

3.配置文件修改code

cp -a ./support-files/my-default.cnf /etc/my.cnf
cp -a ./support-files/mysql.server  /etc/init.d/mysqld

//修改以上文件,修改如下內容
basedir=/opt/mysql
datadir=/opt/mysql/data

//非默認安裝目錄還需配置mysqld
 mkdir -p /usr/local/mysql/bin
 ln -s /opt/mysql/bin/mysqld /usr/local/mysql/bin/mysqld

4.mysql權限配置server

cat /root/.mysql_secret
//啓動mysql
/etc/init.d/mysqld start

//客戶端登陸
./mysql -uroot -p
SET PASSWORD = PASSWORD('root');
use mysql
update user set host = '%' where user = 'root';
相關文章
相關標籤/搜索