Centos 7 中yum安装Mysql和修改mysql配置
一. mysql安装
1.安装MySQL官方的Yum Repository
[root@ecs-7bec-0002 mysql]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
--2018-10-09 18:31:29-- http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm [following]
--2018-10-09 18:31:30-- https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm [following]
--2018-10-09 18:31:31-- https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.36.193.224
Connecting to repo.mysql.com (repo.mysql.com)|23.36.193.224|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25548 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-10.noarch.rpm’ 100%[======================================================================================================================================================================================>] 25,548 --.-K/s in 0.1s 2018-10-09 18:31:32 (204 KB/s) - ‘mysql57-community-release-el7-10.noarch.rpm’ saved [25548/25548] -c: No such file or directory
No URLs found in -c.
FINISHED --2018-10-09 18:31:32--
Total wall clock time: 3.3s
Downloaded: 1 files, 25K in 0.1s (204 KB/s)
2.下载所需要的rpm包
[root@ecs-7bec-0002 mysql]# yum -y install mysql57-community-release-el7-10.noarch.rpm
Loaded plugins: fastestmirror, langpacks
Examining mysql57-community-release-el7-10.noarch.rpm: mysql57-community-release-el7-10.noarch
Marking mysql57-community-release-el7-10.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-10 will be installed
--> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================================================================
Installing:
mysql57-community-release noarch el7-10 /mysql57-community-release-el7-10.noarch 30 k Transaction Summary
================================================================================================================================================================================================================================
Install 1 Package Total size: 30 k
Installed size: 30 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql57-community-release-el7-10.noarch 1/1
Verifying : mysql57-community-release-el7-10.noarch 1/1 Installed:
mysql57-community-release.noarch 0:el7-10 Complete!
[root@ecs-7bec-0002 mysql]#
3.安装MySQL所需要的服务,这一步执行的时间比较长
如果中间需要输入y/n,则输入y继续执行
[root@ecs-7bec-0002 mysql]# yum -y install mysql-community-server
Loaded plugins: fastestmirror, langpacks
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql57-community | 2.5 kB 00:00:00
(1/3): mysql-tools-community/x86_64/primary_db | 45 kB 00:00:00
(2/3): mysql-connectors-community/x86_64/primary_db | 26 kB 00:00:00
(3/3): mysql57-community/x86_64/primary_db | 152 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: 100.125.0.40
* extras: 100.125.0.40
* updates: 100.125.0.40
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.23-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.23-1.el7 for package: mysql-community-server-5.7.23-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.23-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.23-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.23-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.23-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.23-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.23-1.el7 will be obsoleting
--> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.23-1.el7 mysql57-community 2.2 M
replacing mariadb-libs.x86_64 1:5.5.52-1.el7
mysql-community-libs-compat x86_64 5.7.23-1.el7 mysql57-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.52-1.el7
mysql-community-server x86_64 5.7.23-1.el7 mysql57-community 165 M
Installing for dependencies:
mysql-community-client x86_64 5.7.23-1.el7 mysql57-community 24 M
mysql-community-common x86_64 5.7.23-1.el7 mysql57-community 274 k Transaction Summary
================================================================================================================================================================================================================================
Install 3 Packages (+2 Dependent packages) Total download size: 194 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY ] 0.0 B/s | 70 kB --:--:-- ETA
Public key for mysql-community-common-5.7.23-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-5.7.23-1.el7.x86_64.rpm | 274 kB 00:00:01
(2/5): mysql-community-libs-5.7.23-1.el7.x86_64.rpm | 2.2 MB 00:00:00
(3/5): mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm | 2.0 MB 00:00:00
(4/5): mysql-community-client-5.7.23-1.el7.x86_64.rpm | 24 MB 00:00:04
(5/5): mysql-community-server-5.7.23-1.el7.x86_64.rpm | 165 MB 00:00:20
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 8.4 MB/s | 194 MB 00:00:22
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>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-10.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-5.7.23-1.el7.x86_64 1/6
Installing : mysql-community-libs-5.7.23-1.el7.x86_64 2/6
Installing : mysql-community-client-5.7.23-1.el7.x86_64 3/6
Installing : mysql-community-server-5.7.23-1.el7.x86_64 4/6
Installing : mysql-community-libs-compat-5.7.23-1.el7.x86_64 5/6
Erasing : 1:mariadb-libs-5.5.52-1.el7.x86_64 6/6
Verifying : mysql-community-server-5.7.23-1.el7.x86_64 1/6
Verifying : mysql-community-libs-5.7.23-1.el7.x86_64 2/6
Verifying : mysql-community-client-5.7.23-1.el7.x86_64 3/6
Verifying : mysql-community-libs-compat-5.7.23-1.el7.x86_64 4/6
Verifying : mysql-community-common-5.7.23-1.el7.x86_64 5/6
Verifying : 1:mariadb-libs-5.5.52-1.el7.x86_64 6/6 Installed:
mysql-community-libs.x86_64 0:5.7.23-1.el7 mysql-community-libs-compat.x86_64 0:5.7.23-1.el7 mysql-community-server.x86_64 0:5.7.23-1.el7 Dependency Installed:
mysql-community-client.x86_64 0:5.7.23-1.el7 mysql-community-common.x86_64 0:5.7.23-1.el7 Replaced:
mariadb-libs.x86_64 1:5.5.52-1.el7 Complete!
[root@ecs-7bec-0002 mysql]#
4.启动mysql服务
[root@ecs-7bec-0002 mysql]# service mysqld start //启动命令
[root@ecs-7bec-0002 mysql]# service mysqld status //查看服务状态
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2018-10-09 19:05:20 CST; 2min 42s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 5868 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 5763 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 5871 (mysqld)
CGroup: /system.slice/mysqld.service
└─5871 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Oct 09 19:04:54 ecs-7bec-0002 systemd[1]: Starting MySQL Server...
Oct 09 19:05:20 ecs-7bec-0002 systemd[1]: Started MySQL Server.
[root@ecs-7bec-0002 mysql]#
二. mysql基本配置
1.查看mysql中root用户的原始密码,每次安装mysl,系统就会生成一个随机密码。注意冒号后面的才是密码(红色部分)
[root@ecs-7bec-0002 ~]# grep 'temporary password' /var/log/mysqld.log
2018-10-09T11:05:15.914001Z 1 [Note] A temporary password is generated for root@localhost: )o=cCvgXJ0%1
2.登入root用户,并在回车后输入密码
[root@ecs-7bec-0002 ~]# mysql -uroot -p
Enter password:
3.我们需要修改下root的密码,但是mysql对密码有要求,我们需要修改两个全局参数:
validate_password_policy:
- 1:符合长度,且必须含有数字,小写或大写字母,特殊字符。
- 0:判断密码的标准就基于密码的长度了。
validate_password_length:代表密码长度,最小值为4
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec) mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '设置的密码';
Query OK, 0 rows affected (0.00 sec) mysql>
三. mysql远程配置
1.数据库安装完毕,密码重置成功,下面是在本地远程连接在服务器中的mysql
此命名的意思是:
- 使某个ip的账户已用户名:user,密码:pwd连接服务器中的mysql。
- 执行此命令会自动创建不存在的账户和其密码
user:可以直接使用root账户,也可以创建一个账户;
ip:可以是一个具体的ip,也可以用“%”代替,%代表的是所有的IP地址
pwd:新创建一个密码,不建议直接使用root的密码
GRANT ALL PRIVILEGES ON *.* TO 'user'@'ip' IDENTIFIED BY 'pwd' WITH GRANT OPTION;
FLUSH PRIVILEGES;
使用此命令刷新权限,使上一步的配置生效
FLUSH PRIVILEGES
如果此时远程登录还是不成功,请检查服务器3306是否对外开放,检查防火墙是对外开放的端口是否有3306
防火墙端口检查和端口规则帮助:https://www.cnblogs.com/zhaosongbin/p/9765599.html
四. 其他
1.mysql常用文件路径:
/etc/my.cnf 这是mysql的主配置文件
/var/lib/mysql mysql数据库的数据库文件存放位置
/var/log mysql 数据库的日志输出存放位置
2.mysql基本命令:
service mysqld start 启动mysql服务
service mysqld status 查看mysql服务状态
service mysqld stop 关闭mysql服务
service mysqld restart 重启mysql服务
参考:
https://blog.csdn.net/qq_38663729/article/details/79327305
https://blog.csdn.net/babycan5/article/details/81950096
Centos 7 中yum安装Mysql和修改mysql配置的更多相关文章
- centos下利用yum安装LAMP(Linux+Apache+MySQL+PHP)及配置
先说下我的实践配置,centos6.5(64位),联网 安装前准备:关闭防火墙 service iptables stop 安装MySQL 打开终端,root用户 1 yum install mysq ...
- 【转】CentOS环境下yum安装LAMP(Linux+Apache+Mysql+php)
此种方法很简单.每次都用源码编译,浪费好多时间啊! 同样的网站程序在Linux下运行要比在windows下快出不少,所以决定使用Linux的发行版CentOS ,本文主要讲解在CentOS下使用yum ...
- CentOS环境下yum安装LAMP(Linux+Apache+Mysql+php)
CentOS下使用yum命令 安装LAMP详细过程.我们使用的软件是CentOS的最新版本CentOS 6.3,其他版本的也基本类似. 第一步:更新系统内核(如果不想更新可以跳过本步). 首先更新系统 ...
- centos 7中 yum安装jdk
yum安装jdk的好处就是不需要手动再配置环境变量,所有的变量都是自动生成 1.检查系统是否存在jdk,存在删除原版jdk 如果没有信息输出,则表示没有安装jdk rpm -qa |grep java ...
- 在Centos中yum安装和卸载软件的使用方法(转)
在Centos中yum安装和卸载软件的使用方法 安装方法 安装一个软件时 yum -y install httpd 安装多个相类似的软件时 yum -y install httpd* 安装多个非类似软 ...
- 在Centos中yum安装和卸载软件的使用方法(转载)
转自: http://gzmaster.blog.51cto.com/299556/72278 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任. ...
- <亲测>CentOS中yum安装ffmpeg
CentOS中yum安装ffmpeg 1.升级系统 sudo yum install epel-release -y sudo yum update -y sudo shutdown -r now 2 ...
- python在CentOS 7中的安装
CentOS 7 中默认安装了python2.7.5,可能部分开发人员需要使用python3系列的产品,因为版本不“向下”兼容,诸如print函数,因此需要对于不同的项目进行python版本之间的切换 ...
- 转:CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP)环境
CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP) 今天遇到一个网友提到需要在Linux VPS服务器中安装LAMP(Apache/MySQL/PHP)网站环 ...
随机推荐
- 在win10 64 bit上安装theano
在windows10上安装theano,过程例如以下: 1.准备工作.先安装Anaconda 64位.然后执行 conda install mingw libpython 2.先安装pycuda,能够 ...
- jquery选中表格的某行变色
<tr ng-click="+"selectRow("+i+");"+" ng-mouseover="+"chan ...
- CSS3:box-sizing:不再为盒子模型而烦恼
题外话: W3C奉行的标准,就是content-box,就是须要计算边框,填充还有内容的;可是就我个人而言, 比較喜欢的是传统IE6时候的怪异模式,不用考虑容器是否会被撑开(打乱布局); 盒子模型差异 ...
- oc52--autorelease1
// // main.m /* autorelease也是用于内存管理的,给对象发送autorelease消息就会把对象放入autoreleasepool这个池子中,当池子销毁的时候会对池子里面的所有 ...
- C# Interactive Walkthrough
C# Interactive Walkthrough
- nodejs--Nodejs单元测试小结
前言 最近在写一课程的Project,用Node写了一个实时聊天小应用,其中就用到了单元测试.在写Node单元测试的时候,一方面感受到了单元测试的重要性,另一方面感受到了Node单元测试的不够成熟,尚 ...
- fsockopen get,post 封装 (转)
function http_request($url, $method = 'GET', $postfields = NULL, $headers = array()) { $parse = pa ...
- Winform 异步调用2 时间
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 5.7 Liquibase:与具体数据库独立的追踪、管理和应用数据库Scheme变化的工具。-mybatis-generator将数据库表反向生成对应的实体类及基于mybatis的mapper接口和xml映射文件(类似代码生成器)
一. liquibase 使用说明 功能概述:通过xml文件规范化维护数据库表结构及初始化数据. 1.配置不同环境下的数据库信息 (1)创建不同环境的数据库. (2)在resource/liquiba ...
- Android BroadcastReceiver 发送有序广播
普通广播(Normal Broadcast): 一,优缺点:和有序广播的优缺点相反! 二,发送广播的方法:sendBroadcast() 有序广播(Ordered Broadcast): 一,优缺点 ...