1. 程式人生 > >Linux安裝MySQL8.0.12之二進位制安裝

Linux安裝MySQL8.0.12之二進位制安裝

開發十年,就只剩下這套架構體系了! >>>   

Linux安裝MySQL8.0.12之二進位制安裝

2018年07月29日 01:21:31 vkingnew 閱讀數:6050   版權宣告:本文為博主原創文章,轉載請註明出處 https://blog.csdn.net/vkingnew/article/details/81267223
 
  1.   執行環境:centos+mysql8.0.12
  2.   1.下載官方打包好的二進位制安裝包:
  3.   #wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  4.   可以看到這個版本採用了tar.xz的打包壓縮方式,檔案只有350M左右,下載還是滿方便的。
  5.   # du -sh mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  6.   339M mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  7.    
  8.   2.解壓檔案:
  9.   #tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
  10.   # mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql
  11.    
  12.   3.配置引數檔案:
  13.   # cat /etc/my.cnf
  14.   [mysqld]
  15.   server-id = 1
  16.   port = 3306
  17.   mysqlx_port = 33060
  18.   mysqlx_socket = /tmp/mysqlx.sock
  19.   datadir = /data/mysql
  20.   socket = /tmp/mysql.sock
  21.   pid-file = /tmp/mysqld.pid
  22.   log-error = error.log
  23.   slow-query-log = 1
  24.   slow-query-log-file = slow.log
  25.   long_query_time = 0.2
  26.   log-bin = bin.log
  27.   relay-log = relay.log
  28.   binlog_format =ROW
  29.   relay_log_recovery = 1
  30.   character-set-client-handshake = FALSE
  31.   character-set-server = utf8mb4
  32.   collation-server = utf8mb4_unicode_ci
  33.   init_connect ='SET NAMES utf8mb4'
  34.   innodb_buffer_pool_size = 1G
  35.   join_buffer_size = 128M
  36.   sort_buffer_size = 2M
  37.   read_rnd_buffer_size = 2M
  38.   log_timestamps = SYSTEM
  39.   lower_case_table_names = 1
  40.   default-authentication-plugin =mysql_native_password
  41.    
  42.   4.建立目錄授權等:
  43.   # groupadd mysql
  44.   # useradd mysql
  45.   # mkdir -p /data/mysql
  46.   # chown -R mysql:mysql /data/mysql/
  47.   # chmod -R 775 /data/mysql/
  48.    
  49.    
  50.   5.初始化資料庫:
  51.   #/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure
  52.   官方推薦使用--initialize,會在錯誤日誌中生成難以輸入的臨時密碼,我這裡使用的免密碼的方式。
  53.    
  54.   # cat /data/mysql/error.log | grep -i password
  55.   2018-07-29T02:06:41.253856+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wquR3-Kxlg1d
  56.    
  57.    
  58.   6.設定啟動檔案和環境變數:
  59.   #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  60.   --啟動資料庫:
  61.   # /etc/init.d/mysql start
  62.   Starting MySQL.Logging to '/data/mysql/error.log'.
  63.   SUCCESS!
  64.    
  65.   # vim /etc/profile.d/mysql.sh
  66.   # cat /etc/profile.d/mysql.sh
  67.   export PATH=$PATH:/usr/local/mysql/bin
  68.   # source /etc/profile.d/mysql.sh
  69.   # mysqld --version
  70.   mysqld Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
  71.   [root@node4 mysql]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock
  72.   Enter password:
  73.   Welcome to the MySQL monitor. Commands end with ; or \g.
  74.   Your MySQL connection id is 7
  75.   Server version: 8.0.12 MySQL Community Server - GPL
  76.    
  77.   Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  78.    
  79.   Oracle is a registered trademark of Oracle Corporation and/or its
  80.   affiliates. Other names may be trademarks of their respective
  81.   owners.
  82.    
  83.   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  84.    
  85.   mysql> select version();
  86.   +-----------+
  87.   | version() |
  88.   +-----------+
  89.   | 8.0.12 |
  90.   +-----------+
  91.   1 row in set (0.00 sec)
  92.   7.設定可以遠端登入的賬號:
  93.   mysql> show variables like '%valid%pass%';
  94.   Empty set (0.00 sec)
  95.    
  96.   mysql> create user root@'%' identified by 'oracle';
  97.   ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
  98.   mysql> show variables like '%valid%pass%';
  99.   ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  100.   mysql> alter user root@'localhost' identified by 'oracle';
  101.   Query OK, 0 rows affected (0.07 sec)
  102.    
  103.   mysql> show variables like '%valid%pass%';
  104.   Empty set (0.01 sec)
  105.   --建立可以遠端登入的使用者:
  106.   mysql> create user root@'%' identified by 'oracle';
  107.   Query OK, 0 rows affected (0.06 sec)
  108.    
  109.   mysql> grant all privileges on *.* to root@'%' with grant option;
  110.   Query OK, 0 rows affected (0.07 sec)
  111.    
  112.   mysql> flush privileges;
  113.   Query OK, 0 rows affected (0.00 sec)
  114.    
  115.   總結:
  116.   官方雖然提供RPM安裝方式但是不少預設引數還是不太方便平常的使用,對生產而言則需要修改更多的地方,但是很適合初級使用者快速安裝使用;
  117.   而對二進位制安裝包 只需要下載按照自定義的設定安裝即可 方便快捷 可自主配置,適合生產佈署。