這篇文章主要介紹了關於linux編譯安裝mysql5.7,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下
mysql編譯安裝
添加使用者
useradd -s /usr/sbin/nologin -r mysql
下載源碼包以及解壓
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.21.tar.gztar -zxf mysql-boost-5.7.21.tar.gzcd mysql-5.7.21
安裝擴充依賴
yum remove mariadb-libsyum install gcc -yyum install gcc-c++ -yyum install cmake -yyum install libaio -yyum install ncurses-devel -y
建立mysql的安裝目錄及資料庫存放目錄
mkdir -p /data/db/mysqlmkdir -p /data/log/mysql
編譯安裝mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DSYSCONFDIR=/usr/local/mysql/etc \-DMYSQL_DATADIR=/data/mysql \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DWITH_SYSTEMD=1 \-DWITH_SSL=system \-DWITH_ZLIB=system \-DWITH_EMBEDDED_SERVER=1 \-DENABLED_LOCAL_INFILE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8mb4 \-DDEFAULT_COLLATION=utf8mb4_general_ci \-DDOWNLOAD_BOOST=1 \-DWITH_BOOST=/usr/local/boostmake -j8 && make install
檢驗是否安裝成功
[root@root mysql-5.7.12]# cd /usr/local/mysql/[root@root mysql]# lsbin data include man mysql.sock.lock README support-filesCOPYING docs lib mysql.sock mysql-test share
建立目錄
mkdir -p /data/db/mysql/mkdir -p /data/log/mysql/
增加設定檔
mkdir /usr/local/mysql/etctouch /usr/local/mysql/etc/my.cnfln -s /usr/local/mysql/etc/my.cnf /usr/local/etc
修改許可權
chown -R mysql:mysql /usr/local/mysql/*chown -R mysql:mysql /data/db/mysql /data/log/mysql
產生初始化密碼
cd /usr/local/mysqlbin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/db/mysqlbin/mysql_ssl_rsa_setupvim /data/log/mysql/error.log查看初始化密碼grep 'temporary password' /data/log/mysql/error.log
將mysql的啟動服務添加到系統服務中
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/systemmkdir -p /var/run/mysqld/chown mysql:mysql /var/run/mysqldsystemctl start mysqldservice mysql start
啟動mysql
service mysqld start檢查mysql啟動是否正常service mysqld status 或者 ps -ef | grep mysql設定mysqld服務開機自啟動systemctl enable mysqld.service檢查mysqld開機自啟動是否設定成功systemctl list-dependencies | grep mysqld
修改mysql密碼,以及遠端連線許可權
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Studytime%';use mysql;select host, user from user;update user set host = '%' where user = 'root';GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Studytime%' WITH GRANT OPTION;FLUSH PRIVILEGES;
以上就是本文的全部內容,希望對大家的學習有所協助,更多相關內容請關注topic.alibabacloud.com!
相關推薦:
PHP7.2 Data Structures的使用
php編譯安裝擴充redis及swoole的方法