国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

CentOS7源碼編譯安裝MySQL5.7

roadtogeek / 3419人閱讀

摘要:一安裝準(zhǔn)備官網(wǎng)下載頁二下載在下載頁,選擇的版本。創(chuàng)建用戶組和用戶設(shè)置權(quán)限的安裝目錄為初始化數(shù)據(jù)庫結(jié)果生成了一個臨時密碼,這個要記錄下來。解決編輯配置文件,然后將寫入其中。

一、安裝準(zhǔn)備

MySQL官網(wǎng) https://www.mysql.com/

MySQL下載頁 https://dev.mysql.com/downloa...

二、下載MySQL

在MySQL下載頁,選擇MySQL的版本。

選擇版本 MySQL Community Server 5.7.23

選擇 Source Code

選擇 Generic Linux (Architecture Independent)

選擇帶boost版本的 mysql-boost-5.7.23.tar.gz

復(fù)制鏈接地址

下載MySQL

yum -y install wget
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.23.tar.gz
三、環(huán)境依賴

源碼方式安裝MySQL所需的環(huán)境依賴:

cmake

make

gcc

gcc-c++

bison

ncurses

ncurses-devel(devel是開發(fā)版本)

yum -y install cmake make gcc gcc-c++ bison ncurses ncurses-devel
四、安裝MySQL 1. 解壓mysql包
tar -zxvf mysql-boost-5.7.23.tar.gz
cd mysql-5.7.23/
2. 創(chuàng)建編譯目錄
mkdir configure
cd configure
3. 生成編譯環(huán)境
cmake .. -DWITH_BOOST=../boost/boost_1_59_0/ -DWITH_EMBEDDED_SERVER=OFF

結(jié)果:

-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.7.23/configure
可能遇到的問題:

問題1

MySQL currently requires boost_1_59_0...

解決:因為下載的帶boost的版本,只需指定正確的 -DWITH_BOOST 參數(shù)即可,如下

-DWITH_BOOST=../boost/boost_1_59_0/

如果是不帶boost的版本,需要自己下載,并移動至解壓的mysql-5.7.23目錄下,在生成編譯文件時,指定正確的 -DWITH_BOOST 參數(shù)即可

wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download
tar -zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 mysql-5.7.23

或者指定cmake參數(shù),系統(tǒng)會自己下載

-DDOWNLOAD_BOOST=1 -DWITH_BOOST 

問題2

make[2]: *** [libmysqld/examples/mysql_client_test_embedded] 錯誤 1
make[1]: *** [libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/all] 錯誤 2

解決:添加以下參數(shù)

-DWITH_EMBEDDED_SERVER=OFF
4. 編譯安裝

整個過程可能需要點(diǎn)時間,耐心等待。

make && make install
5. 創(chuàng)建mysql用戶組和用戶
groupadd mysql
useradd -g mysql mysql
6. 設(shè)置權(quán)限

MySQL的安裝目錄為 /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql
7. 初始化數(shù)據(jù)庫
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql

2018-07-29T19:09:18.304497Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-07-29T19:09:18.536280Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-07-29T19:09:18.586523Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-07-29T19:09:18.649604Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e49ee151-9362-11e8-ab75-08002739fe2b.
2018-07-29T19:09:18.653045Z 0 [Warning] Gtid table is not ready to be used. Table "mysql.gtid_executed" cannot be opened.
2018-07-29T19:09:18.653886Z 1 [Note] A temporary password is generated for root@localhost: A,uNFfDrd1yd

結(jié)果:生成了一個臨時密碼,這個要記錄下來。同時有個警告

TIMESTAMP with implicit DEFAULT value is deprecated。

解決:

vim /etc/my.cnf

編輯配置文件,然后將 explicit_defaults_for_timestamp=true 寫入其中。

8. 將mysql加入系統(tǒng)服務(wù)
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysql
chkconfig --add mysql # 加入系統(tǒng)服務(wù)
chkconfig mysql on # 開機(jī)啟動
9. 嘗試開啟MySQL服務(wù)
service mysql start

遇到問題,如下:

Starting MySQL.2018-07-30T01:14:39.000931Z mysqld_safe error: log-error set to "/var/log/mariadb/mariadb.log", however file don"t exists. Create writable for user "mysql".
 ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).

解決:創(chuàng)建該文件即可

mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb/mariadb.log

再次開啟mysql服務(wù)

[root@localhost support-files]# service mysql start
Starting MySQL. SUCCESS!

服務(wù)開啟成功了!

10. 登錄mysql
[root@localhost support-files]# mysql -u root -p
-bash: mysql: 未找到命令
解決未找到命令問題

創(chuàng)建軟鏈接

ln -s /usr/local/mysql/bin/mysql /usr/local/bin

結(jié)果:

[root@localhost ~]# ll -a /usr/local/bin
總用量 0
drwxr-xr-x.  2 root root  19 7月  30 16:36 .
drwxr-xr-x. 15 root root 169 7月  30 02:58 ..
lrwxrwxrwx.  1 root root  26 7月  30 16:36 mysql -> /usr/local/mysql/bin/mysql
再次登錄:
遇到問題
[root@localhost ~]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can"t connect to local MySQL server through socket "/tmp/mysql.sock" (2)
解決方法

查找 mysql.sock 文件,發(fā)現(xiàn)存在于 /var/lib/mysql/ 目錄下。

[root@localhost ~]# find / -name "mysql.sock"
/var/lib/mysql/mysql.sock

再查看配置文件 my.cnf

[mysqld]
  2 datadir=/var/lib/mysql
  3 socket=/var/lib/mysql/mysql.sock
  4 explicit_defaults_for_timestamp=true

從配置文件看出socket值為 /var/lib/mysql/mysql.sock,那么可以創(chuàng)建軟鏈接到 /tmp/mysql.sock

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
重新登錄mysql

如果在初始化數(shù)據(jù)庫時,沒有記錄生成的臨時密碼,那就得“暴力破解”了。

首先,關(guān)閉mysql服務(wù)

service mysql stop

接著,修改/etc/my.cnf,添加skip-grant-tables,如下

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

skip-grant-tables

然后,免密登錄并修改登錄密碼

mysql
# 設(shè)置賬戶密碼并退出
update user set authentication_string=password("PASSWORD") where user="root";
flush privileges;

最后,將/etc/my.cnf中的skip-grant-tables刪除或注釋掉。

重啟服務(wù),使用密碼登錄

[root@localhost support-files]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.23

Copyright (c) 2000, 2018, 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>
提示重置自動生成的密碼:
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改root用戶的密碼
mysql> alter user "root"@"localhost" identified by "123123";
Query OK, 0 rows affected (0.00 sec)

或者

mysql> set password for root@localhost=password("123123");
Query OK, 0 rows affected, 1 warning (0.00 sec)
重新登錄MySQL
mysql> exit
Bye
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.23 Source distribution

Copyright (c) 2000, 2018, 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>
操作數(shù)據(jù)庫
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>
五、總結(jié)

好記性不如爛筆頭,得養(yǎng)成記錄的習(xí)慣了。

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/30126.html

相關(guān)文章

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<