您好,登錄后才能下訂單哦!
源碼安裝mysql
tar zxf mysql-boost-5.7.11.tar.gz
rpm -ivh cmake-2.8.12.2-4.el6.x86_64.rpm
yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y
cd mysql-5.7.11/
yum install gcc-c++ ncurses-devel bison -y
檢測
[root@server2mysql-5.7.11]#
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql #安裝目錄
-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data#數據庫存放目錄
-DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock #Unix socket文件路徑-DWITH_MYISAM_STORAGE_ENGINE=1 #安裝 myisam 存儲引擎-DWITH_INNOBASE_STORAGE_ENGINE=1# 安裝 innodb 存儲引擎-DWITH_PARTITION_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1
#安裝數據庫分區
-DDEFAULT_CHARSET=utf8 #使用 utf8 字符
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/
make && make install##這個編譯過程時間需要一個小時左右
##在make install 階段如果出現很多紅色的字體,并且界面卡住了,可以直接ctrl +C中斷安裝狀態,重新執行make install即可
重新編譯時,需要清除舊的對象文件和緩存信息
make clean
rm -f CmakeCache.txt
然后再繼續camak,make && make install
cd /usr/local/lnmp/mysql/bin
[root@server2 bin]# vim ~/.bash_profile
10 PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin#這樣就能自動補齊
[root@server2 bin]# source ~/.bash_profile#刷新,立即生效
[root@server2 bin]# cd ..
[root@server2 mysql]# cd support-files/
[root@server2 support-files]# rpm -e `rpm -qa | grep mysql` --nodeps
warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave
說明:由于本機之前安裝過mysql 所以源碼安裝的時候需要清除環境影響
這里還不能直接yum remove。yum remove會把軟件的依賴性一起刪除,并且會導致postfix等服務啟動出現故障。
[root@server2 support-files]# yum install mysql-libs -y
[root@server2 support-files]# yum check
[root@server2 support-files]# /etc/init.d/postfix restart#檢測是否排除上文提及的問題
關閉 postfix: [確定]
啟動 postfix: [確定]
[root@server2 support-files]# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@server2 support-files]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@server2 support-files]# cp /etc/my.cnf /etc/my.cnf.bak
[root@server2 support-files]# cp my-default.cnf /etc/my.cnf
cp:是否覆蓋"/etc/my.cnf"? y
[root@server2 support-files]# file mysql.server
mysql.server: POSIX shell script text executable
[root@server2 support-files]# cp mysql.server /etc/init.d/mysqld#復制啟動腳本
[root@server2 mysql]# cd /var/lib/
[root@server2 lib]# /etc/init.d/mysqld status
ERROR! MySQL is not running
[root@server2 lib]# cd /usr/local/lnmp/mysql/
[root@server2 mysql]# ls
bin COPYING docs include lib man mysql-test README share support-files
[root@server2 mysql]# ll
總用量 56
drwxr-xr-x 2 root root 4096 3月 22 23:38 bin
-rw-r--r-- 1 root root 17987 2月 2 2016 COPYING
drwxr-xr-x 2 root root 4096 3月 22 23:37 docs
drwxr-xr-x 3 root root 4096 3月 22 23:37 include
drwxr-xr-x 4 root root 4096 3月 22 23:38 lib
drwxr-xr-x 4 root root 4096 3月 22 23:37 man
drwxr-xr-x 10 root root 4096 3月 22 23:38 mysql-test
-rw-r--r-- 1 root root 2478 2月 2 2016 README
drwxr-xr-x 28 root root 4096 3月 22 23:38 share
drwxr-xr-x 2 root root 4096 3月 22 23:38 support-files
[root@server2 mysql]# grep mysql /etc/passwd#查看mysql這個用戶信息
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
[root@server2 mysql]# grep mysql /etc/shadow
mysql:!!:17218::::::
[root@server2 mysql]# chown mysql.mysql . -R#將當前目錄下所有文件的所有人所有組都設置成mysql -R表示第歸
[root@server2 mysql]# which mysql
/usr/local/lnmp/mysql/bin/mysql
[root@server2 mysql]# mysql_install_db --user=mysql --basedir=/usr/local/lnmp/mysql/ --datadir=/usr/local/lnmp/mysql/data
2017-03-23 00:24:03 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
##mysql_install_db這個命令是不被認同的,讓我們用mysqld --initialize這個命令
2017-03-23 00:24:42 [WARNING] The bootstrap log isn't empty:
2017-03-23 00:24:42 [WARNING] 2017-03-22T16:24:03.786590Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2017-03-22T16:24:03.792333Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-03-22T16:24:03.792343Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
[root@server2 mysql]# pwd
/usr/local/lnmp/mysql
[root@server2 mysql]# cd data/
[root@server2 data]# rm -fr *
[root@server2 data]# cd ..
[root@server2 mysql]# mysqld --initialize --user=mysql --basedir=/usr/local/lnmp/mysql/ --datadir=/usr/local/lnmp/mysql/data
當最后輸出如下:
2017-03-22T16:27:58.726507Z 1 [Note] A temporary password is generated for root@localhost: W_Ad1p4htKk-##加粗字體是mysql的初始登陸密碼
[root@server2 mysql]# chown root.root . -R
[root@server2 mysql]# chown mysql data -R
[root@server2 mysql]# cd data/
[root@server2 data]# ls
auto.cnf ibdata1 ib_logfile1 performance_schema
ib_buffer_pool ib_logfile0 mysql sys
[root@server2 mysql]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@server2 data]# ls
auto.cnf ib_logfile1 mysql.sock server2.example.com.pid
ib_buffer_pool ibtmp1 mysql.sock.lock sys
ibdata1 mysql performance_schema
ib_logfile0 mysqld_safe.pid server2.example.com.err
報錯信息會記錄再server2.example.com.err文件中
[root@server2 data]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.11
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> alter user root@localhost identified by 'lyitx+110';##重新設置密碼
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
這樣mysql就安裝成功了!!!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。