官網地址:https://dev.mysql.com/downloads/mysql/html
我這裏是RHEL6.5的系統,所以選擇RedHat 6 x86,64bit操做系統---下載第一個RPM Bundle便可--mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar。node
目前MySQL8.0.11社區版提供了多種多樣的安裝方式,你也能夠經過下載Linux Generic安裝包mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz來安裝,這種安裝方式無需考慮包兼容性,本文只描述rpm安裝方式。python
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar
若是上述連接失效,通常是由於官網已經更新了新版本,找到最新版本的版本號修改下載便可。mysql
1、mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar解壓後有以下7個文件:linux
-rw-r--r-- 1 root root 28987588 Apr 9 01:06 mysql-community-client-8.0.11-1.el6.x86_64.rpm -rw-r--r-- 1 root root 672184 Apr 9 01:06 mysql-community-common-8.0.11-1.el6.x86_64.rpm -rw-r--r-- 1 root root 4443296 Apr 9 01:06 mysql-community-devel-8.0.11-1.el6.x86_64.rpm -rw-r--r-- 1 root root 2579460 Apr 9 01:06 mysql-community-libs-8.0.11-1.el6.x86_64.rpm -rw-r--r-- 1 root root 1902676 Apr 9 01:06 mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm -rw-r--r-- 1 root root 395918848 Apr 9 01:07 mysql-community-server-8.0.11-1.el6.x86_64.rpm -rw-r--r-- 1 root root 49092596 Apr 9 01:07 mysql-community-test-8.0.11-1.el6.x86_64.rpm
而後建立mysql用戶:算法
useradd mysql passwd mysql
2、安裝順序爲:(強烈建議裝以前先把以前的或自帶的mysql相關包所有卸載,rpm -e --nodeps <包名>便可)sql
rpm -ivh mysql-community-common-8.0.11-1.el6.x86_64.rpm \ mysql-community-libs-8.0.11-1.el6.x86_64.rpm \ mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm \ mysql-community-client-8.0.11-1.el6.x86_64.rpm \ mysql-community-server-8.0.11-1.el6.x86_64.rpm \ mysql-community-devel-8.0.11-1.el6.x86_64.rpm
3、安裝完畢後相關信息以下:session
[root@python ~]# mysql -V mysql Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL) [root@python ~]# ll /etc/init.d/mysqld -rwxr-xr-x 1 root root 7166 Apr 8 16:21 /etc/init.d/mysqld [root@python ~]# ll /etc/my.cnf --配置文件位置 -rw-r--r-- 1 root root 1188 Apr 8 16:21 /etc/my.cnf
默認的datadir是在/var/lib/mysql/,能夠經過修改my.cnf修改,啓動命令以下:app
[root@python ~]# service mysqld start Initializing MySQL database: [ OK ] Starting mysqld: [ OK ]
4、使用默認密碼登陸MySQLide
在安裝完後,/var/log/mysqld.log裏應該含有臨時的root密碼,能夠直接登陸,你能夠將此root密碼更改成本身更熟悉的密碼。
mysql> alter user root@'localhost' identified by 'mysql'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
這裏存在密碼複雜度要求(在Windows平臺使用msi安裝mysql時,則有自主選擇密碼認證方式的步驟,能夠比較方便的進行設置。):
mysql> show variables like '%pass%'; +----------------------------------------------+-----------------+ | Variable_name | Value | +----------------------------------------------+-----------------+ | caching_sha2_password_auto_generate_rsa_keys | ON | | caching_sha2_password_private_key_path | private_key.pem | | caching_sha2_password_public_key_path | public_key.pem | | default_password_lifetime | 0 | | disconnect_on_expired_password | ON | | mysql_native_password_proxy_users | OFF | | password_history | 0 | | password_reuse_interval | 0 | | report_password | | | sha256_password_auto_generate_rsa_keys | ON | | sha256_password_private_key_path | private_key.pem | | sha256_password_proxy_users | OFF | | sha256_password_public_key_path | public_key.pem | | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 8 | | validate_password.mixed_case_count | 1 | | validate_password.number_count | 1 | | validate_password.policy | MEDIUM | | validate_password.special_char_count | 1 | +----------------------------------------------+-----------------+
因而設置爲0,而後將validate_password.length設置爲4,表示最少須要4字符。之因此設置爲4是由於這個參數的值不能小於以下公式的計算結果:
validate_password.number_count + validate_password.special_char_count + (2 * validate_password.mixed_case_count)
5、建一個測試用戶leo,嘗試遠程鏈接下吧:
$ mysql -uleo -pmysql -h192.168.1.193 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
我這5.7的mysql工具都連不上,這就尷尬了,查看認證相關參數:
mysql> show variables like '%auth%'; +-------------------------------+-----------------------+ | Variable_name | Value | +-------------------------------+-----------------------+ | default_authentication_plugin | caching_sha2_password | +-------------------------------+-----------------------+ 1 row in set (0.02 sec)
查看官網發現此值的取值以下:
官網還說此值影響create user不顯式指定auth plugin時密碼的默認加密算法,這意味着低版本的mysql工具基本連不上8.0,簡單起見咱們直接使用之前的加密算法。
mysql> select user,host,plugin from mysql.user; +------------------+-----------+-----------------------+ | user | host | plugin | +------------------+-----------+-----------------------+ | leo | % | caching_sha2_password | | mysql.infoschema | localhost | mysql_native_password | | mysql.session | localhost | mysql_native_password | | mysql.sys | localhost | mysql_native_password | | root | localhost | caching_sha2_password | +------------------+-----------+-----------------------+
在my.cnf裏添加:default_authentication_plugin=mysql_native_password,而後service mysqld restart重啓服務,如下只演示leo用戶的建立:
mysql> drop user leo; Query OK, 0 rows affected (0.10 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> create user leo identified by 'mysql'; Query OK, 0 rows affected (0.02 sec) mysql> grant all on *.* to leo; Query OK, 0 rows affected (0.08 sec)
$mysql -V mysql Ver 14.14 Distrib 5.7.20, for Linux (x86_64) using EditLine wrapper $ mysql -uleo -pmysql -h192.168.1.193 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 16 Server version: 8.0.11 MySQL Community Server - GPL Copyright (c) 2000, 2017, 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>
至此遠程鏈接正常。