CentOS 6 安装 MySQL 8.0.x

1.先查询是否安装MySQL

大多数CentOS 6 自带 MySQL5.1

命令:

rpm -qa|grep mysql

执行:

[root@lifan ~]# rpm -qa|grep mysql mysql-libs-5.1.73-7.el6.i686 2.若有则卸载 rpm -e --nodeps mysql-libs

--nodeps 是消除依赖的意思

3.去官网复制yum下载链接用wget下载到服务器 https://dev.mysql.com/downloads/repo/yum/

CentOS 6 安装 MySQL 8.0.x


CentOS 6 安装 MySQL 8.0.x

命令:

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

执行成功结果:

[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

执行后会跳出2次选择,输入y回车继续即可,如:

[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继续安装:

... 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 <mysql-build@oss.Oracle.com> Package: mysql80-community-release-el6-1.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Is this ok [y/N]: y

最后出现如下指令,安装成功:

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启动状态:

[root@lifan ~]# service mysqld status mysqld (pid 3852) is running... 7.查看系统给root自动生成的密码 cat /var/log/mysqld.log

执行结果(密码在第二行最后):

[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之后,必须修改密码后才能操作. 并且对密码要求严格,至少8位,包含大小写等,若想设置成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)

设置密码:

mysql> alter user user() identified by '123456'; Query OK, 0 rows affected (0.09 sec) 9.远程登录(Navicat)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/88670405d02abf2996b0a7d525f6e466.html