ssh secure 安装mysql_centos7 安装mysql
安装环境或方式
环境: centos7_64
安装方式:官网下载安装mysql-server
ps:mysql安装其实不难,但是并没有把步骤记下来,所以我把安装的步骤整理出来方便以后使用
安装mysql
顺序执行下列语句
[root@db01 mysql]# cd /usr/local/mysql
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
配置mysql
配置编码格式
/etc/my.cnf 最后面添加 default-character-set =utf8
default-character-set =utf8
设置密码
mysql> set password for 'root'@'localhost' =password('123456');
Query OK, 0 rows affected (0.01 sec)
新建用户
mysql> create user 'hdfs'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
表的所有权限赋值给位于所有IP地址的root用户
mysql> grant all privileges on *.* to root@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
刷新修改
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
安装过程日志
[root@db01 mysql]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
--2019-02-13 10:04:20-- http://dev.mysql.com/get/mysql-community-release-el7-5.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... dRead error (Connection reset by peer) in headers.
Retrying.
--2019-02-13 10:04:31-- (try: 2) http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
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/mysql-community-release-el7-5.noarch.rpm [following]
--2019-02-13 10:04:34-- https://dev.mysql.com/get/mysql-community-release-el7-5.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//mysql-community-release-el7-5.noarch.rpm [following]
--2019-02-13 10:04:36-- https://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 173.223.96.113
Connecting to repo.mysql.com (repo.mysql.com)|173.223.96.113|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6140 (6.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-release-el7-5.noarch.rpm’
100%[==========================================================================>] 6,140 --.-K/s in 0s
2019-02-13 10:04:38 (34.2 MB/s) - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]
[root@db01 mysql]# ll
total 8
-rw-r--r--. 1 root root 6140 Nov 12 2015 mysql-community-release-el7-5.noarch.rpm
[root@db01 mysql]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-release-el7-5 ################################# [100%]
[root@db01 mysql]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 68490.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 36 M RSS (860 MB VSZ)
Started: Wed Feb 13 10:04:58 2019 - 00:07 ago
State : Running, pid: 68490
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 44 M RSS (868 MB VSZ)
Started: Wed Feb 13 10:04:58 2019 - 00:09 ago
State : Sleeping, pid: 68490
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 47 M RSS (872 MB VSZ)
Started: Wed Feb 13 10:04:58 2019 - 00:11 ago
State : Sleeping, pid: 68490
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 47 M RSS (872 MB VSZ)
Started: Wed Feb 13 10:04:58 2019 - 00:13 ago
State : Sleeping, pid: 68490
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.43-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.43-2.el7 for package: mysql-community-server-5.6.43-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.43-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.43-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.43-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.43-2.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
---> Package mysql-community-libs.x86_64 0:5.6.43-2.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
mysql-community-libs x86_64 5.6.43-2.el7 mysql56-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-server x86_64 5.6.43-2.el7 mysql56-community 59 M
Installing for dependencies:
mysql-community-client x86_64 5.6.43-2.el7 mysql56-community 20 M
mysql-community-common x86_64 5.6.43-2.el7 mysql56-community 257 k
Transaction Summary
====================================================================================================================
Install 2 Packages (+2 Dependent packages)
Total download size: 81 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.43-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.43-2.el7.x86_64.rpm is not installed
(1/4): mysql-community-common-5.6.43-2.el7.x86_64.rpm | 257 kB 00:00:03
(2/4): mysql-community-libs-5.6.43-2.el7.x86_64.rpm | 2.0 MB 00:00:40
(3/4): mysql-community-client-5.6.43-2.el7.x86_64.rpm | 20 MB 00:06:53
(4/4): mysql-community-server-5.6.43-2.el7.x86_64.rpm | 59 MB 00:27:40
--------------------------------------------------------------------------------------------------------------------
Total 49 kB/s | 81 MB 00:28:25
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering "
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql-community-release-el7-5.noarch (installed)
From : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-5.6.43-2.el7.x86_64 1/5
Installing : mysql-community-libs-5.6.43-2.el7.x86_64 2/5
Installing : mysql-community-client-5.6.43-2.el7.x86_64 3/5
Installing : mysql-community-server-5.6.43-2.el7.x86_64 4/5
Erasing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 5/5
Verifying : mysql-community-server-5.6.43-2.el7.x86_64 1/5
Verifying : mysql-community-common-5.6.43-2.el7.x86_64 2/5
Verifying : mysql-community-libs-5.6.43-2.el7.x86_64 3/5
Verifying : mysql-community-client-5.6.43-2.el7.x86_64 4/5
Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 5/5
Installed:
mysql-community-libs.x86_64 0:5.6.43-2.el7 mysql-community-server.x86_64 0:5.6.43-2.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.6.43-2.el7 mysql-community-common.x86_64 0:5.6.43-2.el7
Replaced:
mariadb-libs.x86_64 1:5.5.60-1.el7_5
Complete!
[root@db01 mysql]# ll
total 8
-rw-r--r--. 1 root root 6140 Nov 12 2015 mysql-community-release-el7-5.noarch.rpm
[root@db01 mysql]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
s[root@db01 mysql]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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报错
在退出来重新连接mysql的时候报错,无论是用root还是新建的用户hdfs,看起来像是密码没有生效
[root@db01 hdfs]# mysql -uhdfs -p'123456'
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'hdfs'@'localhost' (using password: YES)
通过查阅资料,发现这个错误一般是由密码错误引起,解决的办法自然就是重置密码。在这之前我也重置过密码,至于为什么没生效搞懂,应该是方法不对,所以在规范了重置密码后这个问题就解决了
现在连mysql都连接不上,更谈不上重置密码之类的操作了(也许有方法直接重置,但是我母鸡啊)
那么就要通过一下步骤来重置密码了
MySQL的密码认证过程
[root@db01 mysql]# vim /etc/my.cnf
在文件中 [mysqld] 下添加 skip-grant-tables #添加跳过密码验证的语句
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
skip-grant-tables #添加跳过密码验证的语句
#
# 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
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default-character-set =utf8
wq 保存文档并退出
接下来
service mysqld restart #重启mysql 有些用 service mysql restart
mysql #免密码登陆
use mysql; 切换数据库
update user set password=password("123456") where user="root"; #修改密码
flush privileges; #刷新修改
quit ;#退出
操作如下
[root@db01 mysql]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@db01 mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> 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
mysql> update user set password=password("123456") where user="root";
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
接下来my.cnf,去掉或者注释掉刚才添加的内容,保存退出
[mysqld]
# skip-grant-tables #添加跳过密码验证的语句
重新启动mysql
[root@db01 mysql]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@db01 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> exit
Bye
登陆输入用户密码登陆mysql成功
远程连接mysql失败
我的工作环境是windows,通过远程工具连接mysql发现连接失败
在windows下ping远程ip192.168.45.161可以ping通,但是telnet 192.168.45.161 3306确失败了
说明远程端口3306没有开放
所以我们需要开放这个端口
查看防火墙状态
systemctl status firewalld
[root@db01 sysconfig]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-02-12 17:54:57 CST; 1 day 21h ago
Docs: man:firewalld(1)
Main PID: 6201 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─6201 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
如果没有开启则开启防火墙
systemctl start firewalld
systemctl start firewalld
开放端口
// --permanent 永久生效,没有此参数重启后失效
firewall-cmd --zone=public --add-port=3306/tcp --permanent #开放一个指定端口
firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent #开放一个范围端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@db01 sysconfig]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
重启防火墙并查看端口情况
[root@db01 sysconfig]# firewall-cmd --reload
success
[root@db01 sysconfig]# firewall-cmd --zone=public --query-port=3306/tcp
yes
版权声明:本文为博主原创文章,转载请附上博文链接!
ssh secure 安装mysql_centos7 安装mysql相关推荐
- conda 安装mysql_centos7安装mysql
一.安装YUM Repo 1.由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件. 官方网址: https://dev.mysql.com/downloa ...
- cos7安装mysql_centos7 安装 mysql
centos7 安装 mysql 1. 卸载MariaDB, centos 7 自带的 [root@esbu-cos7-01 /]# rpm -qa|grep -i mariadb 用命令卸载 rp ...
- centos7 cmake安装mysql_centos7 安装cmake
在CentOS安装CMake (CentOS7 64位适用) 在CentOS安装CMake 转自:http://www.cnblogs.com/mophee/archive/2013/03/19/29 ...
- centos7解压安装mysql_CentOS7 安装Mysql5.7 解压缩版
1.环境 1.系统CentOS 7 2.数据库Mysql 5.7 2.准备工作 1.从MySQL官网上下载压缩包到本地 运行环境 CentOS 7 下载地址:https://dev.mysql.com ...
- centos7 安装mysql_Centos7安装最新版本的MySQL
点击上方蓝色字体,关注我们 想在Centos7里安装MySQL数据库,但在网上查找了一番,要不是版本太老就是命令遇到问题,爬了许多坑,总结出了最新的安装方法,在此记录一下. 安装MySQL源 在MyS ...
- centos7 无法yum安装mysql_CentOS7 安装mysql(YUM源方式)
1.下载mysql源安装包 2.安装mysql源 $ yum localinstall mysql57-community-release-el7-8.noarch.rpm 3.检查mysql源是否安 ...
- centos7本地安装mysql_centos7安装mysql
mysql安装 1.检查是否本地已经安装了mysql rpm -qa | grep mysql 2.卸载以前的mysql rpm -e 已经存在的MySQL全名 3.下载mysql cd /usr/l ...
- esc centos 安装mysql_CentOS7安装Mysql
1.下载 wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm 2.安装软件源 rpm -Uvh mysql57 ...
- censo7安装mysql_centos7 安装MySQL
在centos7中已经将mysql从yum应用列表中移除,并使用mariadb代替,所以直接通过yum install mysql-server安装时会提示没有可用软件包mysql-server.在c ...
- centos7 php 安装mysql_Centos7 安装mysql
总所周知,MySQL 被 Oracle 收购后,CentOS 的镜像仓库中提供的默认的数据库也变为了 MariaDB 在 CentOS 上安装 MySQL步骤及注意如下 1. 添加 MySQL YUM ...
最新文章
- wpf checkbox选中触发事件_Cypress 可操作事件
- python3项目-Python3基础教程(十九)—— 项目结构
- java多态的简单例子_要JAVA的简单例子,继承\多态的,详细讲解运行的每一步
- [bzoj1062] [NOI2008]糖果雨
- 2018 杭电多校2 - Naive Operations
- matlab衰减指数的程序是,如何用MATLAB仿真单指数衰减振荡波
- java8 新特性实践
- (曲率系列4:)基于点拟合二次曲面并求曲率
- solidworks背景改为纯白色
- 智能电子快递面单系统
- java消息队列ActiveMQ之Comsumer
- Excel 2010 VBA 入门 037 获取最后一行数据的行数
- 好程序员大数据培训分享大数据概述
- 顺丰快递业务接入API总览-快递鸟
- poj 2594 Treasure Exploration
- springboot源码 红色J_通达信精准指标,鱼网兜鱼3.0终结版主图指标,源码免费分享...
- 数据科学家和软件工程师都在用的pandas函数有哪些?
- QRCode二维码扫描和生成
- WAP网站的建设心得
- Java获取一年有多少周、某周的第一天和最后一天.
热门文章
- 在 Win10系统,所有程序默认都以管理员身份运行
- yarn.lock、package-lock.json、npm-shrinkwrap.json的理解
- Linux安装Perl(最新版)
- 【华为】某中小型企业网 组网案例—总公司+分公司模式
- MT【217】韦达定理应用
- 【LoRa点对点通信与控制】
- Google 创始人
- board crt_HTML5 CSS3 朋克风格的旧式CRT显示器
- warning: array subscript is above array bounds
- iP138版 离线iP数据库ip.txt导入Mysql示例