新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS6安裝MySQL8.0.x
1.先查詢是否安裝mysql
大多數(shù)centos 6 自帶 MySQL5.1
創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供云安網(wǎng)站建設(shè)、云安做網(wǎng)站、云安網(wǎng)站設(shè)計、云安網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、云安企業(yè)網(wǎng)站模板建站服務(wù),十年云安做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
命令:
rpm -qa|grep mysql
執(zhí)行:
[root@lifan ~]# rpm -qa|grep mysql
mysql-libs-5.1.73-7.el6.i686
2.若有則卸載
rpm -e --nodeps mysql-libs
--nodeps 是消除依賴的意思
3.去官網(wǎng)復(fù)制yum下載鏈接用wget下載到服務(wù)器
https://dev.mysql.com/downloads/repo/yum/
命令:
wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
成功:
[root@lifan ~]# wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
--2018-12-10 06:40:42--
...
Length: 25800 (25K) [application/x-RedHat-package-manager]
Saving to: “mysql80-community-release-el6-1.noarch.rpm”
2018-12-10 06:40:42 (95.8 MB/s) - “mysql80-community-release-el6-1.noarch.rpm” saved [25800/25800]
若沒有wget
[root@lifan ~]# wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
-bash: wget: command not found
安裝wget
yum -y install wget
4.安裝
第一步:
rpm -ivh mysql80-community-release-el6-1.noarch.rpm
執(zhí)行成功結(jié)果:
[root@lifan ~]# rpm -ivh mysql80-community-release-el6-1.noarch.rpm
warning: mysql80-community-release-el6-1.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql80-community-relea########################################### [100%]
[root@lifan ~]#
第二步:
yum install mysql-server
執(zhí)行后會跳出2次選擇,輸入y回車?yán)^續(xù)即可,如:
[root@lifan ~]# yum install mysql-server
Loaded plugins: fastestmirror
...
Install 5 Package(s)
Total download size: 452 M
Installed size: 1.7 G
Is this ok [y/N]: y
輸入y繼續(xù)安裝:
...
Total 16 MB/s | 452 MB 00:28
warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : MySQL Release Engineering
Package: mysql80-community-release-el6-1.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
最后出現(xiàn)如下指令,安裝成功:
Installed:
mysql-community-server.i686 0:8.0.13-1.el6
Dependency Installed:
mysql-community-client.i686 0:8.0.13-1.el6 mysql-community-common.i686 0:8.0.13-1.el6 mysql-community-libs.i686 0:8.0.13-1.el6 numactl.i686 0:2.0.9-2.el6
Complete!
5.查詢是否安裝成功
[root@lifan ~]# mysqladmin -V
mysqladmin Ver 8.0.13 for Linux on i686 (MySQL Community Server - GPL)
6.開啟MySqL
[root@lifan ~]# service mysqld start
Initializing MySQL database:
[ OK ]
Starting mysqld: [ OK ]
查看MySQL啟動狀態(tài):
[root@lifan ~]# service mysqld status
mysqld (pid 3852) is running...
7.查看系統(tǒng)給root自動生成的密碼
cat /var/log/mysqld.log
執(zhí)行結(jié)果(密碼在第二行最后):
[root@lifan ~]# cat /var/log/mysqld.log
2018-12-10T12:19:20.303739Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server in progress as process 3620
2018-12-10T12:19:24.878215Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >J9tXQXwK3y=
2018-12-10T12:19:29.237165Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server has completed
2018-12-10T12:19:32.011310Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.13) starting as process 3852
2018-12-10T12:19:33.144590Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-12-10T12:19:33.201007Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.13' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
2018-12-10T12:19:33.272837Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
8.命令行登錄和修改密碼
[root@lifan ~]# mysql -uroot -p
Enter password:
輸入上一步驟查看的密碼(輸入時不顯示任何字符):
[root@lifan ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.
...
mysql>
修改密碼:
mySql5.7之后,必須修改密碼后才能操作.
并且對密碼要求嚴(yán)格,至少8位,包含大小寫等,若想設(shè)置成123456,則要以下兩條命令:
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=1;
Query OK, 0 rows affected (0.00 sec)
設(shè)置密碼:
mysql> alter user user() identified by '123456';
Query OK, 0 rows affected (0.09 sec)
9.遠(yuǎn)程登錄(Navicat)
注意:需關(guān)閉防火墻或者開放3306端口
service iptables stop #暫時關(guān)閉
chkconfig iptables off #設(shè)置成開啟不自啟
==========
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT #開啟3306端口
/etc/rc.d/init.d/iptables save #保存配置
/etc/rc.d/init.d/iptables restart #重啟服務(wù)
遠(yuǎn)程登錄會報如下錯誤:
mysql> use mysql;
Database changed
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
mysql> update user set host = '%' where user ='root';
再刷新一下:
flush privileges;
這時該問題已解決,若報如下錯誤,則是版本加密方式的改變
登錄后請依次執(zhí)行如下命令:
use mysql;
ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER; #更改加密方式
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';#更新用戶密碼
FLUSH PRIVILEGES;#刷新權(quán)限
再次連接成功:
網(wǎng)站標(biāo)題:CentOS6安裝MySQL8.0.x
本文鏈接:http://www.dlmjj.cn/article/ccejjpd.html


咨詢
建站咨詢

