到官網下載下傳最新的的安裝包:
[[email protected] data]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
解除安裝CentOS7自帶的MariaDB依賴:
[[email protected] selinux]# rpm -qa|grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[[email protected] selinux]# rpm -e --nodeps mariadb-libs
[[email protected] selinux]# rpm -qa|grep mariadb
解壓下載下傳的安裝包
[[email protected] data]# tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
安裝net-tools
[[email protected] data]# yum -y install net-tools
依次安裝mysql包
[[email protected] data]# rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm
[[email protected] data]# rpm -ivh mysql-community-libs*
[[email protected] data]# rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm
[[email protected] data]# rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm
warning: mysql-community-server-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
/usr/bin/perl is needed by mysql-community-server-8.0.13-1.el7.x86_64
perl(Getopt::Long) is needed by mysql-community-server-8.0.13-1.el7.x86_64
perl(strict) is needed by mysql-community-server-8.0.13-1.el7.x86_64
### 安裝缺失的perl依賴包
[[email protected] data]# yum install perl
[[email protected] data]# rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm
啟動mysql,擷取預設root密碼,登入mysql資料庫
[[email protected] data]# systemctl start mysqld.service
[[email protected] data]# grep 'temporary password' /var/log/mysqld.log
2018-11-16T15:15:20.149816Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: J/V3,F-pa;>X
[[email protected] data]# mysql -uroot -p
初始化mysql
[[email protected] data]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: $RFV5tgb
Re-enter new password: $RFV5tgb
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
修改root密碼,建立study使用者
### 初始化時已更改root密碼,這裡可以省略
# mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '$RFV5tgb';
### 這裡是避免SQLyog連接配接8.0報:Error No.2058 Plugin caching_sha2_password could not be loaded,後續工具更新後,再使用8.0新的加密方式
mysql> CREATE USER 'study'@'localhost' IDENTIFIED WITH mysql_native_password BY '^YHN7ujm';
### 授予study所有權限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'study'@'localhost' WITH GRANT OPTION;
用SQLyog進行連接配接
ps: 由于mysql沒有開啟遠端連接配接,通過ssh連接配接跳轉
配置SSH Tunneling
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiI5MGN4UzNjVDO2gTNvwFcvwVbvNmL1h2cuFWaq5yd3d3Lc9CX6MHc0RHaiojIsJye.jpg)
配置ssh
填寫mysql連接配接資訊,注意host填:127.0.0.1
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiI5MGN4UzNjVDO2gTNvwFcvwVbvNmL1h2cuFWaq5yd3d3Lc9CX6MHc0RHaiojIsJye.jpg)
配置mysql連接配接