安装mysql数据库及问题解决方法
1、mysql官网下载安装包,官网地址:www.mysql.com
[root@seiang software]# ll
total 580020
-rw-r--r--. 1 root root 593940480 Mar 25 18:57 mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
2、解压
[root@seiang software]# tar xvf mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.21-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.21-1.el7.x86_64.rpm
mysql-community-common-5.7.21-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.21-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.21-1.el7.x86_64.rpm
mysql-community-client-5.7.21-1.el7.x86_64.rpm
mysql-community-server-5.7.21-1.el7.x86_64.rpm
mysql-community-embedded-5.7.21-1.el7.x86_64.rpm
mysql-community-test-5.7.21-1.el7.x86_64.rpm
mysql-community-devel-5.7.21-1.el7.x86_64.rpm
mysql-community-libs-5.7.21-1.el7.x86_64.rpm
3、全部安装,出现如下的报错
[root@seiang software]# rpm -ivh *.rpm
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mariadb-libs is obsoleted by mysql-community-libs-5.7.21-1.el7.x86_64
mariadb-libs is obsoleted by mysql-community-libs-compat-5.7.21-1.el7.x86_64
perl(Data::Dumper) is needed by mysql-community-test-5.7.21-1.el7.x86_64
perl(JSON) is needed by mysql-community-test-5.7.21-1.el7.x86_64
4、如上的报错,由于centos 7默认是mariadb数据库,再去安装mysql之前要先下载mariadb
[root@seiang software]# rpm -qa | grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@seiang software]# rpm -e mariadb-libs-5.5.41-2.el7_0.x86_64
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
由于存在依赖关系,强制卸载
[root@seiang software]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
5、安装mysql-server,出现报错
[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.21-1.el7.x86_64
mysql-community-common(x86-64) = 5.7.21-1.el7 is needed by mysql-community-server-5.7.21-1.el7.x86_64
6、根据提示,要先安装mysql-community-common和mysql-community-client包
[root@seiang software]# rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.21-1.e################################# [100%]
7、安装mysql-client包,出现如下的报错
[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.21-1.el7.x86_64
8、根据提示先安装 mysql-community-libs包
[root@seiang software]# rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.21-1.el7################################# [100%]
9、再次尝试安装mysql-client
[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.21-1.e################################# [100%]
10、最后安装mysql-server
[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.21-1.e################################# [100%]
11、查看mysql的服务
[root@seiang software]# systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
12、启动mysql服务
[root@seiang software]# systemctl start mysqld.service
[root@seiang software]#
[root@seiang software]# systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Mon 2018-03-26 09:26:04 CST; 2s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2113 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 2034 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 2116 (mysqld)
CGroup: /system.slice/mysqld.service
鈹斺攢2116 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Mar 26 09:25:54 seiang systemd[1]: Starting MySQL Server...
Mar 26 09:26:04 seiang systemd[1]: Started MySQL Server.
13、mysql服务启动成功,首先使用临时的密码进行登录,查看临时密码
[root@seiang software]# grep "password" /var/log/mysqld.log
2018-03-25T11:18:09.770923Z 1 [Note] A temporary password is generated for root@localhost: &)2KIh?M3hr7
2018-03-25T11:19:39.853663Z 2 [Note] Access denied for user 'root'@'localhost' (using password: YES)
2018-03-25T11:22:20.996230Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2018-03-25T11:24:31.219087Z 0 [Note] Shutting down plugin 'validate_password'
2018-03-25T11:24:33.062278Z 0 [Note] Shutting down plugin 'sha256_password'
2018-03-25T11:24:33.062286Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-03-26T01:25:57.938742Z 1 [Note] A temporary password is generated for root@localhost: v,esvf2?oj?T
14、使用临时密码登录,然后修改root的密码
[root@seiang software]# mysql -uroot -pv,esvf2?oj?T
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 2
Server version: 5.7.21
Copyright (c) 2000, 2018, 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>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'beijing';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qcloud@2018';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
两次修改都提示相同的错误:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
下面是官方文档,对于该问题的解释:
https://dev.mysql.com/doc/refman/5.7/en/validate-password.html
上述报错的原因:其实与validate_password_policy的值有关。
validate_password_policy有以下取值:
默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
解决方法:
修改validate_password_policy参数的值
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 8 |
+----------------------------+
1 row in set (0.05 sec)
默认的密码长度是8,少于8位依旧会出现报错
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'beijing';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
修改成功
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qcloud@2018';
Query OK, 0 rows affected (0.00 sec)
15、使用新密码再次登录,登录成功
[root@seiang software]# mysql -uroot -pqcloud@2018
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 4
Server version: 5.7.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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>
16、由于习惯于Linux的提示,所以我们为mysql也设置提示
(1)临时设置
mysql> prompt \u@ \h \d >
root@ localhost (none) >
root@ localhost (none) >use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
root@ localhost mysql >prompt \u@\h [\d]>
PROMPT set to '\u@\h [\d]>'
root@localhost [mysql]>
root@localhost [mysql]>
(2)永久设置
[root@seiang ~]# vim /etc/my.cnf
添加下面两句,注意:[]中是mysql,不是mysqld
[mysql]
prompt=\u@\h [\d]>
安装mysql数据库及问题解决方法的更多相关文章
- ubuntu安装mysql数据库方法
ubuntu基于linux的免费开源桌面PC操作系统,十分契合英特尔的超极本定位,支持x86.64位和ppc架构.一个比较流行的Linux操作系统,不仅简单易用,而且和Windows相容性非常好.那么 ...
- Python安装MySQL数据库模块
背景 折腾: [记录]使用Python操作MySQL数据库 的过程中,需要去安装MySQLdb. 下载MySQLdb 去官网: http://pypi.python.org/pypi/MySQL-py ...
- 二进制包安装MySQL数据库
1.1二进制包安装MySQL数据库 1.1.1 安装前准备(规范) [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径 [ ...
- win8安装SQL Server 2005问题解决方法
win8安装SQL Server 2005问题解决方法 1.正常安装任一版本的SQL Server 2005(最好安装企业版). 2.安装到SqlServer服务的时候提示启动服务失败(提示重试的时候 ...
- CentOS7安装mysql数据库
安装完Centos7,迫不急待的想安装mysql数据库,却没想到走了很多弯路,后来经过查资料,才知道了在Centos7中用MariaDB代替了mysql数据库. 准确来说,本文的标题有点误导的意思,本 ...
- Centos6.4下Yum命令安装Mysql数据库及配置
如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲解了 如果要开发web项目,我们当然可以安装一个 ...
- RedHat 安装MySQL数据库【转】
朋友购买了阿里云的服务器,服务器上自带有CentOS操作系统,但是开发软件需要自己安装,接下来将介绍本地RedHat Linux 5.10虚拟机上搭建Mysql数据库. 一.软件准备 (1)jdk ...
- windows下配置lamp环境(4)---安装MySQL数据库5.6
图解安装MySQL数据库 1.获取软件就多不说了 2.双击开始安装 3.点击点击NEXT进行下一步 4.同意协议,点击NEXT进入下一步 5.选择指定安装位置安装方法,进入安装位值选择页面: 6.分别 ...
- .net安装包自动安装Mysql数据库
原文:.net安装包自动安装Mysql数据库 在制作.Net安装包的时候,如果项目有用到数据库,怎么能够把数据库打包安装呢?网上已经有很多自动安装Sql Server数据库的例子,但是自动安装mysq ...
随机推荐
- MFC编程——Where is WinMain?
源码 #include<afxwin.h> class MyApp :public CWinApp { public: virtual BOOL InitInstance(); }; My ...
- Linux下 expect 使用详解与实例
一.概述 我们通过Shell可以实现简单的控制流功能,如:循环.判断等.但是对于需要交互的场合则必须通过人工来干预,有时候我们可能会需要实现和交互程序如telnet服务器等进行交互的功能.而Expec ...
- Cairo初探
https://blog.csdn.net/flexwang_/article/details/38000401 二维解析pdf
- 一步一步pwn路由器之rop技术实战
前言 本文由 本人 首发于 先知安全技术社区: https://xianzhi.aliyun.com/forum/user/5274 这次程序也是 DVRF 里面的,他的路径是 pwnable/She ...
- HTML5游戏2D开发引擎
1.PixiJS(基于webGl和canvas) 官网:http://www.pixijs.com/ github(star:20672):https://github.com/pixijs/pixi ...
- BZOJ 3894 / Luogu P4313 文理分科 (拆点最小割)
题面 中文题面- BZOJ 传送门 Luogu 传送门 分析 这道题类似于BZOJ 3774 最优选择,然后这里有一篇博客写的很好- Today_Blue_Rainbow's Blog 应该看懂了吧- ...
- python自动华 (一)
Python自动化 [第一篇]:Python简介和入门 Python简介: 一.什么是python Python是一门动态解释性的强类型定义语言. pythonde 特点:“优雅”.“明确”.“简单” ...
- IIS上传限制大小
加入下面的配置即可 <?xml version="1.0" encoding="UTF-8"?> <configuration> < ...
- position:absolute 按钮左右分布:left:0 和 right:0 以及雪碧图
问题:把两个a标签按钮 垂直居中,并且分别把两个按钮放在水平左右两边顶部1,祖父元素设定:position:relative2,把.arrow 设定上下垂直居中 position:absolute; ...
- pyinstaller打包程序包含openpyxl库问题解决
带有openpyxl库时,直接打包,总会失败: 原因:看本地文件...Anaconda3\Lib\site-packages\PyInstaller\hooks\hook-openpyxl.py 发现 ...