mysql5.7編譯安裝

mysql5.7編譯安裝

mkdri /home/data

cd /home/data

rz 軟件包(yum install lrzsz)

mysql-boost-5.7.15.tar.gz 

mysql-5.7.15.tar.gz

cmake-3.5.2.tar.gz


預裝軟件:

yum install -y make gcc gcc-c++ 

yum install -y ncurses-devel 

yum intsall -y bison bison-devel

yum install -y openssl openssl-devel


安裝cmake

wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz


# tar xf cmake-3.5.2.tar.gz

# cd cmake-3.5.2

# ./bootstrap

# gmake 

# gmake install


Boost庫放到預裝位置

 wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

# tar xzvf boost_1_59_0.tar.gz(別的版本報錯,也可以mysql官網下載mysql-boost-5.7.15.tar.gz 包)


編譯安裝mysql

 mkdir -p /usr/local/mysql

 mkdir -p /home/data/mysqldb

 useradd mysql

 cd /home/data

 chown -R mysql:mysql mysqldb

 

tar -xzvf mysql-5.7.15.tar.gz

tar -xzvf mysql-boost-5.7.15.tar.gz 

cd mysql-5.7.15

如果想清理此前的編譯所生成的文件,則需要使用如下命令:

make clean

rm CMakeCache.txt


cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/home/data/mysqldb \

-DSYSCONFDIR=/etc \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DWITH_LIBWRAP=0 \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DWITH_SSL=system \

-DWITH_ZLIB=system \

-DWITH_BOOST=/home/data/mysql-5.7.15/boost \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci




make 

make install




/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysqldb


“–initialize”會生成一個隨機密碼(~/.mysql_secret),而”–initialize-insecure”不會生成密碼

–datadir目標目錄下不能有數據文件



mysql的服務腳本



#拷貝腳本

cp support-files/mysql.server /etc/init.d/mysqld

#賦予權限

chmod +x /etc/init.d/mysqld

#增加至sysV服務

chkconfig --add mysqld

#開機自啓動

chkconfig mysqld on



修改/usr/local/mysql權限


chmod +w /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql

啓動數據庫 

 

service mysqld start


添加環境變量

修改 /etc/profile

末尾追加:export PATH=$PATH:/usr/local/mongodb/bin:/usr/local/mysql/bin


echo 'export PATH=$PATH:/usr/local/mongodb/bin:/usr/local/mysql/bin' >>/etc/profile


source /etc/profile 


dbrootpwd=oneinstack  #數據庫root密碼

/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"

/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"


set password for root@localhost = password('123456');


create user zheng;

update user set authentication_string=password("123456") where user="zheng";

grant all on zheng.* to 'zheng'@'10.116.39.147';

create user text;

update user set authentication_string=password("123456") where user="text";

grant all on text.* to 'text'@'localhost';

3.刷新數據庫 (一定要記得刷新)

mysql>flush privileges

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章