CentOS 7環境下安裝MySQL 8.0.20

  最近在整理數據庫的工作學習筆記,測試機CentOS環境安裝MySQL 8.0.20及簡單使用。

  附帶說幾句有關升級到MySQL 8的幾個問題:

  • 支持從MySQL 5.7(5.7.9或更高版本)升級到8.0,不支持在GA版本之間升級,不支持從非GA版本的MySQL 5.7升級到8.0;
  • 建議在升級到下一個版本之前先升級到最新版本,例如,在升級到MySQL 8.0之前,請先升級到最新的MySQL 5.7版本,不支持跳過。例如,版本升級不支持從MySQL 5.6直接升級到8.0。
  • 當發行版本達到GA狀態時,它支持在版本系列中進行升級(從GA版本替換爲GA版本),例如,從MySQL 8.0.x升級到8.0 .y。(不支持涉及開發狀態的非GA版本升級)也跳過此版本,例如,支持從MySQL 8.0.x升級到8.0 .z,MySQL 8.0 .11是MySQL 8.0版本系列中的第一個GA狀態版本。

  不支持從MySQL 8.0降級到MySQL 5.7,或從MySQL 8.0降級到MySQL 8.0的早期版本,唯一受支持的替代方法是還原升級前做法的備份,因此,必須在開始升級過程之前備份數據。

1. MySQL源代碼包下載

  [root@chengyu ~ ]# mkdir -p /home/softwares/mysql/

  [root@chengcheng ~]# cd /home/softwares/mysql/

  [root@chengcheng mysql]# wget https://dev.mysql.com/get/downloads/MySQL-8.0/mysql-8.0.20.tar.gz

  [root@chengyu mysql]# tar zxvf mysql-8.0.20.tar.gz

2.依賴包安裝
  相關的依賴包要求可以參考:https://dev.mysql.com/doc/refman/8.0/en/source-installation-prerequisites.html

  • cmake-3.5.1以上版本
  • GCC 5.3以上版本

  [root@chengyu mysql]# yum -y install cmake3 gcc gcc-c ++ ncurses ncurses-devel libaio-devel openssl openssl-devel

3. Boost下載安裝

   Mysql 5.7版本更新後有很多變化,比如json等,安裝必須要BOOST庫,不過mysql的官網源碼有帶boost庫的源碼和不帶boost庫的源碼兩種,因此有兩種安裝方式,其實都是一樣的,僅僅是不帶boost庫源碼的需要單獨安裝boost,boost庫可以大大地提高軟件的開發效率,就像C#裏類庫,或者JAVA裏類庫,它是C++的類庫,下載鏈接https://www.boost.org/,MySQL 5.7系列需要boost_1_59_0,MySQL 8需要更高的版本,這裏用boost_1_70_0。

   [root@chengyu mysql-8.0.20]# wget -P /home/softwares/mysql/ https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz
   [root@chengyu mysql]# tar -zxvf /home/softwares/mysql/boost_1_70_0.tar.gz -C /usr/local
   [root@chengyu mysql]# cd /usr/local
   [root@chengyu local]# mv boost_1_70_0 boost
   [root@chengyu local]# cd boost/
   [root@chengyu boost]# ./bootstrap.sh
   [root@chengyu boost]# ./b2 install
4.創建MySQL安裝目錄和數據目錄

  默認情況下,從源代碼編譯安裝MySQL時,安裝一般是在/usr/local/mysql下,因爲本機已經在該目錄下裝有MySQL 5.7.23,另建MySQL8安裝目錄。
   [root@chengyu boost]# mkdir -p /usr/local/mysql8
   [root@chengyu boost]# mkdir -p /home/mysql8
   [root@chengyu boost]# mkdir -p /home/mysql8/data
   [root@chengyu boost]# mkdir -p /home/mysql8/logs

5. MySQL用戶創建

  因爲僅出於所有權目的而不是登錄目的才需要該用戶,所以useradd命令使用-r和-s /bin/false選項來創建對服務器主機沒有登錄權限的用戶。
   [root@chengyu boost]# groupadd mysql
   [root@chengyu boost]# useradd -r -g mysql -s /bin/false mysql
   [root@chengyu boost]# chown -R mysql:mysql /usr/local/mysql8
   [root@chengyu boost]# chown -R mysql:mysql /home/mysql8

6.添加MySQL PATH路徑並開放3307端口
   [root@chengyu boost]# vim /etc/profile
   #for mysql
   export MYSQL_HOME=/usr/local/mysql8
   export PATH=/usr/local/mysql8/bin:/usr/local/mysql8/lib:$PATH
   [root@chengyu boost]# source /etc/profile

  防火牆的3307端口默認沒有開啓,若要遠程訪問,需要開啓這個端口,若關閉了防火牆這個就不用了。
   [root@chengyu ~]# vim /etc/sysconfig/iptables
-A INPUT-m state–state NEW-m tcp-p tcp–dport 3307
-j ACCEPT
   [root@chengyu ~]#/etc/init.d/iptables restart

  或者systemctl restart iptables。
7.使用cmake編譯並安裝MySQL

   [root@chengyu mysql]#cd home/softwares/mysql/mysql-8.0.20/

  [root@chengyu mysql-8.0.20]#cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql8
-DMYSQL_DATADIR=/home/mysql8/data
-DMYSQL_UNIX_ADDR=/usr/local/mysql8/mysql.sock
-DMYSQL_TCP_PORT=3307
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DENABLED_LOCAL_INFILE=1
-DENABLE_DOWNLOADS=1
-DWITH_INNODB_MEMCACHED=ON
-DWITH_BOOST=/usr/local/boost

   結果提示:

- running cmake version 2.8.12.2 CMake warning on CMakeLists.txt: 54 (MESSAGE): Please use cmake3 instead of cmake on this platform-please install cmake3 (please install cmake3 ) CMakeLists.txt: 84 (CMAKE_MINIMUM_REQUIRED) CMake error:
requires CMake 3.5.1 or higher.
You are running version 2.8.12.2-the configuration is incomplete and an error has occurred! &Emsp;   Install cmake3: `

  [root@chengyu mysql-8.0.20]# wget -P /home/softwares/mysql/ https://cmake.org/files/v3.5/cmake-3.5.1.tar.gz

  [root@chengyu mysql]# tar -zxvf cmake-3.5.1.tar.gz

  [root@chengyu mysql]# cd cmake-3.5.1/

  [root@chengyu cmake-3.5.1]# ./bootstrap

  [root@chengyu cmake-3.5.1] # gmake

  [root@chengyu cmake-3.5.1] # make install

  [root@chengyu cmake-3.5.1]# cmake --version

  cmake version 3.5.1

  CMake suite maintained and supported by Kitware (kitware.com/cmake).

   重新編譯安裝:

  [root@chengyu cmake-3.5.1] # cd /home/softwares/mysql/mysql-8.0.20/

  [root@chengyu mysql-8.0.20]# cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql8
-DMYSQL_DATADIR=/home/mysql8/data
-DMYSQL_UNIX_ADDR=/usr/local/mysql8/mysql.sock
-DMYSQL_TCP_PORT=3307
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DENABLED_LOCAL_INFILE=1
-DENABLE_DOWNLOADS=1
-DWITH_INNODB_MEMCACHED=ON
-DFORCE_INSOURCE_BUILD=1
-DWITH_BOOST=/usr/local/boost

  編譯結果報錯:
CMakeLists.txt: CMake warning on 365 (message):
This is an internally generated
-CMAKE_GENERATOR: Unix Makefiles cmake/os/
CMake error on Linux. 76 (message): Requires GCC 5.3 or higher (-dumpversion prompt 4.8.5) Call location (most recent call priority): CMakeLists.txt: 470 (inclusive)-Incomplete configuration, an error has occurred!
Please also pay attention to "/home/softwares/mysql/mysql-8.0.20/CMakeFiles/ Upgrade GCC:

  解決:升級GCC,需要安裝mpc、gmp、mpfr依賴包。

[root@chengyu mysql-8.0.20]# wget -P /home/softwares/mysql/ ftp://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
[root@chengyu mysql-8.0.20]# wget -P /home/softwares/mysql/ ftp://ftp.ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2  
[root@chengyu mysql-8.0.20]# wget -P /home/softwares/mysql/ http://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.gz 
[root@chengyu mysql- 8.0.20]# wget -P /home/softwares/mysql/ http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz 
[root@chengyu mysql-8.0.20]# wget -P /home/softwares/mysql/ http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz 
[root@chengyu mysql-8.0.20]# tar -zxvf /home/softwares/mysql/ mpc-1.1.0.tar.gz -C /home/softwares/mysql/ 
[root@chengyu mysql-8.0.20]# tar -zxvf /home/softwares/mysql/mpfr-4.0 .2.tar.gz -C /home/software/mysql 
[root@chengyu mysql-8.0.20]# tar -jxvf /home/softwares/mysql/gmp-6.1.2.tar.bz2 -C /home/softwares/mysql/ 
[root@chengyu mysql-8.0.20]# tar -zxvf /home/softwares/mysql/m4-1.4.18.tar.gz -C /home/softwares/mysql/
[root@chengyu mysql-8.0.20]# tar -zxvf /home/softwares/mysql/gcc-9.2.0.tar.gz -C /home/softwares/mysql/

  按順序安裝:

[root@chengyu mysql-8.0.20]# mkdir -p /usr/local/m4-1.4.18
[root@chengyu mysql-8.0.20]# mkdir -p /usr/local/gmp-6.1.2 
[root@chengyu mysql-8.0.20]# mkdir -p /usr/local/mpfr-4.0.2 
[root@chengyu mysql-8.0.20]# mkdir -p /usr/local/mpc-1.1.0 
[root@chengyu mysql-8.0.20]# mkdir -p / usr /local/gcc-9.2.0 
[root@chengyu mysql-8.0.20]# / home /softwares/mysql/m4-1.4.18/ configure --prefix = /usr/local/m4-1.4.18 
[root@chengyu mysql-8.0.20]# make && make install 
[root@chengyu mysql-8.0.20]# ln -s /usr/local/m4-1.4.18/bin/m4/ usr/bin/m4 
[root@chengyu mysql-8.0.20]# cd /home/softwares/mysql/gmp-6.1.2/ [root@chengyu gmp-6.1.2]# ./configure --prefix = /usr/local/gmp-6.1.2
[root@chengyu gmp-6.1.2]# make && make install
[root@chengyu mysql]# cd /home/softwares/mysql/mpfr-4.0.2 
[root@chengyu mpfr-4.0.2]# ./configure - -prefix=/usr/local/mpfr-4.0.2/ --with-gmp = / usr /local/gmp-6.1.2/ 
[root@chengyu mpfr-4.0.2]# make && make install 
[root@chengyu mpfr-4.0.2]# cd /home/softwares/mysql/mpc-1.1.0/ 
[root@chengyu mpc-1.1.0]# ./configure --prefix = /usr/local/mpc-1.1.0 --with-gmp = /usr/local/gmp-6.1.2/ --with-mpfr=/usr/local/mpfr-4.0.2/ 
[root@chengyu mpc-1.1.0]# make&&make install 
[root@chengyu mpc-1.1.0]# more /etc/ld.so.conf includeld。因此.conf.d /*.conf /usr/local/gmp-6.1.2/lib /usr/local/mpfr- 4.0.2/lib /usr/local/mpc-1.1.0/lib 
[root@chengyu mpc-1.1.0]# ldconfig 
[root@chengyu mpc-1.1.0]# cd / home /softwares/mysql/gcc-9.2.0/ 
[root@chengyu gcc-9.2.0]# . /configure --prefix = /usr/local/gcc-9.2.0 --with-gmp = /usr/local/gmp-6.1.2 --with-mpfr = /usr/local/mpfr-4.0.2 - with-mpc = /usr/local/mpc-1.1.0 --disable-multilib 
[root@chengyugcc-9.2.0]# make && make install
[root@chengyu gcc-9.2.0]# mv /usr/bin/gcc /usr/bin/gcc4.8.5 
[root@chengyu gcc- 9.2.0]# mv /usr/bin/g++ /usr/bin/g++ 4.8.5 
[root@chengyu gcc-9.2.0]# ln -s /usr/local/gcc- 9.2.0/bin/gcc /usr/bin/gcc [root@chengyu gcc-9.2.0]# ln -s /usr/local/gcc-9.2.0/bin/g++ /usr/bin/g++ [root@chengyu mysql -8.0.20]# make&&make install 

8.安裝
   再次編譯結果提示:

   “Make clean” or “make distclean” does not work), you can * force * use -DFORCE_INSOURCE_BUILD=1 to call cmake to compile the source internally, the configuration is incomplete, and an error will occur! Please also consider "/home /software/mysql

   加上DFORCE_INSOURCE_BUILD=1編譯:

   提示:c++: error: unrecognized command line option ‘-std=c++14’,解決:指定 CXX 的路徑 -DCMAKE_CXX_COMPILER=/usr/bin/g++。

   加上-DCMAKE_CXX_COMPILER=/usr/bin/g++再次編譯:

[root@chengyu mysql-8.0.20]# cmake \
 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql8 \
 -DMYSQL_DATADIR=/home/mysql8/data \
 -DMYSQL_UNIX_ADDR=/usr/local/mysql8/mysql.sock \
 -DMYSQL_TCP_PORT=3307 \
 -DDEFAULT_CHARSET=utf8mb4 \
 -DDEFAULT_COLLATION=utf8mb4_general_ci \
 -DWITH_MYISAM_STORAGE_ENGINE=1 \
 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
 -DENABLED_LOCAL_INFILE=1 \
 -DENABLE_DOWNLOADS=1 \
 -DWITH_INNODB_MEMCACHED=ON \
 -DFORCE_INSOURCE_BUILD=1 \
 -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
 -DWITH_BOOST=/usr/local/boost

   編譯完成,進行安裝:

   [root@chengyu mysql-8.0.20]# make&&make install

   報錯:

   /home/softwares/mysql/mysql-8.0.20/storage/innobase/buf/buf0buf.cc: In function ‘void buf_pool_create(buf_pool_t*, ulint, ulint, std::mutex*, dberr_t&)’:
/home/softwares/mysql/mysql-8.0.20/storage/innobase/buf/buf0buf.cc:1219:44: error: ‘SYS_gettid’ was not declared in this scope
1219 | setpriority(PRIO_PROCESS, (pid_t)syscall(SYS_gettid), -20);
| ^~~~~~~~~~
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/buf/buf0buf.cc.o] Error 1
make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
make: *** [all] Error 2

   解決:
   [root@chengyu mysql-8.0.20]# vim /home/softwares/mysql/mysql-8.0.20/storage/innobase/buf/buf0buf.cc

   第一行添加:#include “sys/syscall.h”

   再次安裝又報錯:

   /home/softwares/mysql/mysql-8.0.20/storage/innobase/lock/lock0lock.cc: In function ‘void lock_mark_trx_for_rollback(hit_list_t&, trx_id_t, trx_t*)’:
/home/softwares/mysql/mysql-8.0.20/storage/innobase/lock/lock0lock.cc:1171:9: error: ‘os_compare_and_swap_thread_id’ was not declared in this scope; did you mean ‘os_compare_and_swap_uint64’?
1171 | cas = os_compare_and_swap_thread_id(&trx->killed_by, 0, thread_id);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| os_compare_and_swap_uint64
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/lock/lock0lock.cc.o] Error 1
make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
make: *** [all] Error 2

   /home/softwares/mysql/mysql-8.0.20/storage/innobase/trx/trx0trx.cc: In function ‘void trx_init(trx_t*)’:
/home/softwares/mysql/mysql-8.0.20/storage/innobase/trx/trx0trx.cc:223:5: error: ‘os_compare_and_swap_thread_id’
was not declared in this scope; did you mean ‘os_compare_and_swap_lint’?
223 | os_compare_and_swap_thread_id(&trx->killed_by, thread_id, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| os_compare_and_swap_lint
   /home/softwares/mysql/mysql-8.0.20/storage/innobase/trx/trx0trx.cc: In function ‘void trx_kill_blocking(trx_t*)’:
/home/softwares/mysql/mysql-8.0.20/storage/innobase/trx/trx0trx.cc:3235:5: error: ‘os_compare_and_swap_thread_id’
was not declared in this scope; did you mean ‘os_compare_and_swap_lint’?
3235 | os_compare_and_swap_thread_id(&victim_trx->killed_by, thread_id, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| os_compare_and_swap_lint
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/trx/trx0trx.cc.o] Error 1
make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
make: *** [all] Error 2

   解決:

   [root@chengyu mysql-8.0.20]# vim /home/softwares/mysql/mysql-8.0.20/storage/innobase/lock/lock0lock.cc

   [root@chengyu mysql-8.0.20]# vim /home/softwares/mysql/mysql-8.0.20/storage/innobase/trx/trx0trx.cc

   將 “os_compare_and_swap_thread_id” 修改爲
os_compare_and_swap_lint。

   好了,現在成功安裝:

   [root@chengyu mysql-8.0.20]# make

   [root@chengyu mysql-8.0.20]# make install
9.設置開機啓動

[root@chengyu mysql-8.0.20]# cd /usr/local/mysql
[root@chengyu mysql8]# cp /usr/local/mysql8/support-files/mysql.server /etc/init.d/mysqld8
[root@chengyu mysql8]# chmod 755 /etc/init.d/mysqld8
[root@chengyu mysql8]# chkconfig --add mysqld8
[root@chengyu mysql8]# chkconfig --level 345 mysqld8 on
[root@chengyu mysql8]# chkconfig --list mysqld8
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld8        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

10.創建配置文件

   從MySQL 5.7.18開始,my-default.cnf不再包含在分發包中或由分發包安裝,這裏從其他版本的MySQL中拷貝一份my-default.cnf,並做相應的修改。

   [root@chengyu mysql8]# vim /etc/my8.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
 basedir =/usr/local/mysql8
 datadir =/home/mysql8/data
 port = 3307
# server_id = .....
 pid-file = /usr/local/mysql8/mysqld.pid
 socket = /usr/local/mysql8/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

11.初始化配置

[root@chengyu ~]# /usr/local/mysql8/bin/mysqld  --defaults-file=/usr/local/mysql8/my.cnf --initialize --basedir=/usr/local/mysql8 --datadir=/home/mysql8/data --user=mysql
2020-06-11T02:18:16.129814Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-06-11T02:18:16.129958Z 0 [System] [MY-013169] [Server] /usr/local/mysql8/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 9060
2020-06-11T02:18:16.138553Z 0 [Warning] [MY-013419] [InnoDB] CLOCK_MONOTONIC is unsupported, so do not change the system time when MySQL is running !
2020-06-11T02:18:16.141580Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-06-11T02:18:21.478754Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-06-11T02:18:31.710740Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9?Vq)B=A6LT!

12.啓動MySQL:

  MySQL啓動腳本和支持的服務器選項組:

[root@chengyu mysql8]# systemctl start mysqld8
[root@chengyu mysql8]# systemctl status mysqld8
● mysqld8.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld8; bad; vendor preset: disabled)
   Active: active (running) since Thu 2020-06-11 10:19:12 CST; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 9154 ExecStart=/etc/rc.d/init.d/mysqld8 start (code=exited, status=0/SUCCESS)
    Tasks: 40
   CGroup: /system.slice/mysqld8.service
           ├─9167 /bin/sh /usr/local/mysql8/bin/mysqld_safe --datadir=/home/mysql8/data --pid-file=/...
           └─9333 /usr/local/mysql8/bin/mysqld --basedir=/usr/local/mysql8 --datadir=/home/mysql8/da...

Jun 11 10:19:09 chengyu systemd[1]: Starting LSB: start and stop MySQL...
Jun 11 10:19:09 chengyu mysqld8[9154]: Starting MySQL.Logging to '/home/mysql8/data/chengyu.err'.
Jun 11 10:19:12 chengyu mysqld8[9154]: .. SUCCESS!
Jun 11 10:19:12 chengyu systemd[1]: Started LSB: start and stop MySQL.
也可以:
[root@chengyu ~]# /usr/local/mysql8/bin/mysqld_safe --defaults-file=/usr/local/mysql8/my.cnf &
[2] 10356
[1]   Done                    /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf
[root@chengyu ~]# 2020-06-11T02:32:21.580777Z mysqld_safe Logging to '/home/mysql8/data/chengyu.err'.
2020-06-11T02:32:21.609504Z mysqld_safe Starting mysqld daemon with databases from /home/mysql8/data

13.登錄數據庫並修改初始密碼:

  使用mysqld --initialize手動執行的數據目錄初始化 , mysqld會生成一個初始隨機密碼,將其標記爲過期,並將其寫入服務器錯誤日誌,root使用該密碼連接到服務器,然後設置新密碼保護初始MySQL帳戶。

[root@chengyu ~]# mysql -uroot -p -P3307
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.20
Copyright (c) 2000, 2020, 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>  set password='mysql8Pass';
Query OK, 0 rows affected (0.13 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

   關於日常工具的安裝很多時候真的十萬個爲什麼,但無暇去深究,先按1-2-3安裝完完成工作先,接下來要整理一下日常工作中常用的一些SQL。

   2020年06月09日,鍾哥說:要不是因爲喜歡你,我會跟她一個毫無關係的人置氣又妥協?…

   這局面我的責任,夾心餅不好做…

   曾看過一句話說:“親情是不可以用加減計算的,有便是全然的不圖回報的付出,沒有則爲零,並不存在中間斤斤計較的地帶”,於此,我不置可否,生來無根似浮萍,又何來情不似紙張張薄…

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