centos 7.3 服务器环境搭建——MySQL 安装和配置
centos 7.3 服务器环境搭建——MySQL 安装和配置
服务器信息如下:
服务器:阿里云
系统 centos 7.3 (阿里云该版本最新系统)
mysql版本:5.7.18 (当前时间最新版本)
连接服务器工具:xshell
1、 配置yum源
更新yum源
yum update
下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
安装MySQL
yum install mysql-community-server
注意:在这过程中会询问的都按y然后回车允许
2、安装MySQL
yum install mysql-community-server
3、启动MySQL
启动MySQL服务
systemctl start mysqld
查看MySQL的启动状态
systemctl status mysqld
设置MySQL开机启动
systemctl enable mysqld
systemctl daemon-reload
4、修改root默认密码
找到root默认密码
grep 'temporary password' /var/log/mysqld.log
进入mysql控制台, 输入上述查询到的默认密码
mysql -uroot -p
第一次登录必须修改初始密码:(最新mysql要求密码必须包含大小写字母和字符,长度大于等于8个字符)
alter user root@localhost identified by '连接密码!';
显示数据库内容
show databases;
查看端口号
show global variables like 'port';
5、添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户
添加远程帐户(密码同上规则)
GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY '连接密码!' WITH GRANT OPTION;
立即生效
flush privileges;
退出mysql操作
exit
总结:
my.cnf文件:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#skip_grant_tables跳过密码直接登录
#validate_password=off 跳过密码强度验证(大小写+特殊字符+数字)
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#--------------------------
#将数据库切换至mysql库
mysql> USE mysql;
#修改密码
mysql> UPDATE user SET authentication_string=PASSWORD(‘数据库连接密码’)WHERE user=’root’;
#刷新MySQL权限相关的表
mysql> flush privileges;
mysql> exit;
添加远程账户访问:
grant all privileges on *.* to 'root'@'%%' identified by '数据库连接密码' with grant option;
立即生效:flush privileges;
update mysql.user set authentication_string=password('数据库连接密码') where user='root';
关闭密码验证:my.cnf文件中加入:validate_password=off
修改密码:
update user set authentication_string=password("数据库连接密码") where user='root';
centos 7.3 服务器环境搭建——MySQL 安装和配置的更多相关文章
- CentOS下Web服务器环境搭建LNMP一键安装包
CentOS下Web服务器环境搭建LNMP一键安装包 时间:2014-09-04 00:50来源:osyunwei.com 作者:osyunwei.com 举报 点击:3797次 最新版本:lnmp- ...
- Linux环境下mysql安装并配置远程访问
环境:centOS 1.下载mysql安装文件 [root@localhost ~]# wget http://dev.mysql.com/get/mysql-community-release-el ...
- Linux环境下服务器环境搭建-mysql
下载对应版本的mysql.rpm(Linux 6 安装el6 Linux 7 安装el7) 安装环境 centos 7,安装版本mysql57-community-release-el7-9.noar ...
- centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课
centos LNMP第一部分环境搭建 LAMP安装先后顺序 LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/local/php/{ ...
- centos LAMP第一部分-环境搭建 Linux软件删除方式,mysql安装,apache,PHP,apache和php结合,phpinfo页面,ldd命令 第十九节课
centos LAMP第一部分-环境搭建 Linux软件删除方式,mysql安装,apache,PHP,apache和php结合,phpinfo页面,ldd命令 第十九节课 打命令之后可以输入: e ...
- LNAMP服务器环境搭建(手动编译安装)
LNAMP服务器环境搭建(手动编译安装) 一.准备材料 阿里云主机一台,操作系统CentOS 6.5 64位 lnamp.zip包(包含搭建环境所需要的所有软件) http://123.56.144. ...
- 服务器环境搭建系列(四)-mysql篇
1.按照上一篇服务器环境搭建系列(三)-JDK篇中的方法检查系统是否已经预装Mysql并卸载. 2.下载mysql,这里是MySQL-server-5.5.25-1.linux2.6.x86_64.r ...
- Windows环境搭建mysql服务器
Windows环境搭建mysql服务器: 1.下载mysql-installer-community-5.7.3.0-m13.2063434697并安装 安装详细步骤>> 2.安装mys ...
- CentOS 6.5系统使用yum方式安装LAMP环境和phpMyAdmin,mysql8.0.1/mysql5.7.22+centos7,windows mysql安装、配置
介绍如何在CentOs6.2下面使用YUM配置安装LAMP环境,一些兄弟也很喜欢使用编译的安装方法,个人觉得如果不是对服务器做定制,用yum安装稳定简单,何必去download&make&am ...
随机推荐
- 实时计算轻松上手,阿里云DataWorks Stream Studio正式发布
Stream Studio是DataWorks旗下重磅推出的全新子产品.已于2019年4月18日正式对外开放使用.Stream Studi是一站式流计算开发平台,基于阿里巴巴实时计算引擎Flink构建 ...
- IDEA 通过数据库生成entity实体类
IDEA利用数据库生成entity类教程 1.在左上角有一个View 选项 2. 然后选择 TOOL Windows 3. 然后选择Database然后会弹出一个窗口 4.选择+号 5.选择data ...
- getopt、getopt_long和getopt_long_only解析命令行参数
一:posix约定: 下面是POSIX标准中关于程序名.参数的约定: 程序名不宜少于2个字符且不多于9个字符: 程序名应只包含小写字母和阿拉伯数字: 选项名应该是单字符或单数字,且以短横 '-' 为前 ...
- H3C 数据链路层
- Codeforces Round #174 (Div. 1 + Div. 2)
A. Cows and Primitive Roots 暴力. B. Cows and Poker Game 模拟. C. Cows and Sequence 线段树维护. D. Cow Progra ...
- 2002年NOIP普及组复赛题解
题目涉及算法: 级数求和:入门题: 选数:搜索: 产生数:搜索.高精度: 过河卒:动态规划. 级数求和 题目链接:https://www.luogu.org/problemnew/show/P1035 ...
- AIM Tech Round (Div. 2)
A. Save Luke 题意:给一个人的长度d,然后给一个区间长度0~L,给你两个子弹的速度v1,v2,两颗子弹从0和L向中间射去(其实不是子弹,是一种电影里面那种绞牙机之类的东西就是一个人被困在里 ...
- vue创建脚手架 cil
1.检查环境是否安装好了!node -vnpm -vnpm install cnpm -g --registry=https://registry.npm.taobao.orgcpm -v (版本与n ...
- H3C 静态路由实现路由备份和负载分担
- UVa 11134 - Fabled Rooks——[问题分解、贪心法]
We would like to place n rooks, ≤ n ≤ , on a n × n board subject to the following restrictions • The ...