CentOS 6 安装 MySQL 8.0.x

栏目: 服务器 · 发布时间: 5年前

内容简介:大多数CentOS 6 自带 MySQL5.1命令:执行:

1.先查询是否安装MySQL

大多数CentOS 6 自带 MySQL 5.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-<a href="https://www.linuxidc.com/topicnews.aspx?tid=10" target="_blank" title="RedHat">RedHat</a>-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.<a href="https://www.linuxidc.com/topicnews.aspx?tid=12" target="_blank" title="Oracle">Oracle</a>.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)

注意:需关闭防火墙或者开放3306端口

service iptables stop #暂时关闭
chkconfig iptables off #设置成开启不自启
==========
/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 #重启服务

远程登录会报如下错误:

CentOS 6 安装 MySQL 8.0.x 首先查看用户表,发现登录主机是localhost,当然不能登录,把root用户的localhost设置为%,这样任意主机都可以连接。

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;

这时该问题已解决,若报如下错误,则是版本加密方式的改变

CentOS 6 安装 MySQL 8.0.x

登录后请依次执行如下命令:

use mysql; 

ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER; #更改加密方式

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';#更新用户密码

FLUSH PRIVILEGES;#刷新权限

再次连接成功:

CentOS 6 安装 MySQL 8.0.x

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址: https://www.linuxidc.com/Linux/2018-12/155819.htm


以上所述就是小编给大家介绍的《CentOS 6 安装 MySQL 8.0.x》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

C语言的科学和艺术

C语言的科学和艺术

罗伯茨 / 翁惠玉 / 机械工业出版社 / 2005-3 / 55.00元

《C语言的科学和艺术》是计算机科学的经典教材,介绍了计算机科学的基础知识和程序设计的专门知识。《C语言的科学和艺术》以介绍ANSI C为主线,不仅涵盖C语言的基本知识,而且介绍了软件工程技术以及如何应用良好的程序设计风格进行开发等内容。《C语言的科学和艺术》采用了库函数的方法,强调抽象的原则,详细阐述了库和模块化开发。此外,《C语言的科学和艺术》还利用大量实例讲述解决问题的全过程,对开发过程中常见......一起来看看 《C语言的科学和艺术》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

SHA 加密
SHA 加密

SHA 加密工具