Mysql安装维护笔记一
1.Centos7安装mysql
rpm安装PHP7相应的yum源
$wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
$sudo rpm -Uvh mysql57-community-release-el7-.noarch.rpm
[root@master2020 mysql]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 141
mysql-connectors-community-source MySQL Connectors Community - disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 105
mysql-tools-community-source MySQL Tools Community - Sourc disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 404
mysql57-community-source MySQL 5.7 Community Server - disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - disabled
如果对别的版本有需求,安装需要的版本就行,只需用yum-config-manager启用或禁用相关的源即可,比如说禁用MySQL5.7启用MySQL5.6
#yum-config=manager 工具安装
yum -y install yum-utils
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql56-community
安装MySQL Server
yum install mysql-community-server
2.mysql默认端口修改
vi /etc/my.cnf
3.启动、停止服务
service mysqld start
service mysqld stop
4.查看密码
grep 'temporary password' /var/log/mysqld.log
5.初始化安全设置
mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: ##输入上面的临时root密码
The existing password for the user account root has expired. Please set a new password.
New password: ##设置新密码
Re-enter new password: ##重复密码
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password:
Change the password for root ? ((Press y|Y for Yes, any other key for No) : #是否更改root密码
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : ##是否移除匿名用户
... skipping.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y ##是否禁止root远程登录
Success. By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y ##是否删除测试数据库
- Dropping test database...
Success. - Removing privileges on test database...
Success. Reloading the privilege tables will ensure that all changes
made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y ##是否立即刷新权限
Success. All done!
6.登陆
mysql -uroot -p
7.创建数据库、用户
create database if not exists databasename default character set utf8 collate utf8_unicode_ci;
create user username@'%' IDENTIFIED BY '!@#$%^1234';
flush privileges;
8.数据库赋用户权限
grant all privileges on databasename.* to username@localhost identified by '!@#$%^1234';
flush privileges;
9.验证新建用户
mysql -u username -p
10.远程访问数据库
vim /etc/my.cnf #修改配置文件
[mysqld]
bind-address=0.0.0.0
#端口加入防火墙
grant all privileges on databasename.* to 'username'@'%' identified by '!@#$%^1234';
flush privileges;
11.卸载mysql
#rpm -qa|grep php # rpm -e php-mysql-5.1.-.el5_5.
# rpm -e php-pdo-5.1.-.el5_5.
# rpm -e php-xml-5.1.-.el5_5.
# rpm -e php-cli-5.1.-.el5_5.
# rpm -e php-gd-5.1.-.el5_5.
# rpm -e php-common-5.1.-.el5_5.
#无法卸载的可以使用
rpm -e php-common-5.1.-.el5_5. --nodeps
Mysql安装维护笔记一的更多相关文章
- Mysql学习笔记(三)对表数据的增删改查。
正文内容. 这一部分是最简单的,也是最麻烦的.简单是因为其实只包括增删该插四个部分.大体上看,增加数据.删除数据.修改数据.查询数据都不麻烦啊,我们日常都是常用的.这个谁不会呢?以前在培训机构学mys ...
- MySQL学习笔记一
MySQL 学习笔记 一 一.数据库简单介绍 1. 按照数据库的发展时间顺序,主要出现了以下类型数据库系统: Ø 网状型数据库 Ø 层次型数据库 Ø 关系型数据库 Ø 面向对象数据库 上面4中数据库系 ...
- MYSQL基础笔记(六)- 数据类型一
数据类型(列类型) 所谓数据烈性,就是对数据进行统一的分类.从系统角度出发时为了能够使用统一的方式进行管理,更好的利用有限的空间. SQL中讲数据类型分成三大类:1.数值类型,2.字符串类型和时间日期 ...
- MYSQL基础笔记(五)- 练习作业:站点统计练习
作业:站点统计 1.将用户的访问信息记录到文件中,独占一行,记录IP地址 <?php //站点统计 header('Content-type:text/html;charset=utf-8'); ...
- MYSQL基础笔记(四)-数据基本操作
数据操作 新增数据:两种方案. 1.方案一,给全表字段插入数据,不需要指定字段列表,要求数据的值出现的顺序必须与表中设计的字段出现的顺序一致.凡是非数值数据,到需要使用引号(建议使用单引号)包裹. i ...
- MYSQL基础笔记(三)-表操作基础
数据表的操作 表与字段是密不可分的. 新增数据表 Create table [if not exists] 表名( 字段名 数据类型, 字段名 数据类型, 字段n 数据类型 --最后一行不需要加逗号 ...
- MYSQL基础笔记(二)-SQL基本操作
SQL基本操作 基本操作:CRUD,增删改查 将SQL的基本操作根据操作对象进行分类: 1.库操作 2.表操作 3.数据操作 库操作: 对数据库的增删改查 新增数据库: 基本语法: Create da ...
- MYSQL基础笔记(一)
关系型数据库概念: 1.什么是关系型数据库? 关系型数据库:是一种建立在关系模型(数学模型)上的数据库 关系模型:一种所谓建立在关系上的模型. 关系模型包含三个方面: 1.数据结构:数据存储的问题,二 ...
- MySQL入门笔记
MySQL入门笔记 版本选择: 5.x.20 以上版本比较稳定 一.MySQL的三种安装方式: 安装MySQL的方式常见的有三种: · rpm包形式 · 通用二进制 ...
随机推荐
- day6 作业 购物车
- Ubuntu 安装MySQL并打开远程连接
首先使用su命令切换到root账户 在用apt-get install mysql-server命令获取到MySQL的服务 等待下载安装,按照提示输入MySQL的密码 安装完成后对mysqld.cnf ...
- 【剑指Offer面试编程题】题目1372:最大子向量和--九度OJ
题目描述: HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学.今天JOBDU测试组开完会后,他又发话了:在古老的一维模式识别中,常常需要计算连续子向量的最大和,当向量全为正数的时候,问题很好解决.但 ...
- Linux CentOS7 VMware 相对和绝对路径、cd命令、mkdir/rmdir、rm命令——笔记
一. 相对和绝对路径 绝对路径是从/(也被称为根目录)开始的,比如/usr.cd /root/ pwd 注:判断用户当前所处的位置 相对路径是以 . 或 .. 开始的 二.cd命令 cd 是进入到当前 ...
- Fiddler抓取HTTPS
对于想抓取HTTPS的测试初学者来说,常用的工具就是fiddler.可是在初学时,大家对于fiddler如何抓取HTTPS真是伤了脑筋,可能你一步步按着网上的帖子成功了,那当然是极好的. 有可能没有成 ...
- ROS-5 : 自定义消息
自定义消息一般存储在功能包的msg文件夹下的.msg文件中,这些定义可告诉ROS这些数据的类型和名称,以便于在ROS 节点中使用.添加完这些自定义消息后,ROS会将其转为等效的C++节点,从而可在其他 ...
- python默认参数问题
我们在定义默认参数时,有时会遇到一写似乎难以理解的问题.比如,在第二次调用函数时,默认参数记住了上一次执行的结果: >>> def test(L=[3,]): ... L.appen ...
- NPM概述及使用简介
什么是 NPM npm之于Node,就像pip之于Python,gem之于Ruby,composer之于PHP. npm是Node官方提供的包管理工具,他已经成了Node包的标准发布平台,用于Node ...
- 2017 北京网络赛 E Cats and Fish
Cats and Fish 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They ...
- vue axios 数据请求实现
1.安装nginx npm install axios --save-dev cnpm install axios --save-dev 使用淘宝镜像 保存依赖文件到本地 装好了.packjson.j ...