Centos7环境MySQL安装简易方法

Centos7环境MySQL5.6在线安装方法
备注:先确保centos可以联网,然后使用root账户登录centos,再如下五个步骤进行实施安装。

第一步使用rpm 工具进行在线下载MYSQL对应工程包
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
获取http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-release-el7-5 ################################# [100%]

第二步安装MYSQL客户端和服务端
一般来说,只要安装mysql-server跟mysql-client
**# yum -y install mysql-community-server
这个时候根据个人网速快慢,会下载对应的各种工程包进行自动安装,需要一段时间,安装结束如下信息:

*作为依赖被安装:
mysql-community-client.x8664 0:5.6.28-2.el7 mysql-community-common.x8664 0:5.6.28-2.el7
perl-Compress-Raw-Bzip2.x8664 0:2.061-3.el7 perl-Compress-Raw-Zlib.x8664 1:2.061-4.el7
perl-DBI.x8664 0:1.627-4.el7 perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7

替代:
mariadb-libs.x8664 1:5.5.40-1.el70 *

完毕!
**第三步,设置开机启动

systemctl enable mysqld

启动mysql服务进程

systemctl start mysqld

第四部,设置密码
重置密码

mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we‘ll need the current
password for the root user. If you‘ve just installed MySQL, and
you haven‘t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y [设置root用户密码]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

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? [Y/n] y [删除匿名用户]
... Success!

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? [Y/n] n [禁止root远程登录]
... skipping.

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? [Y/n] y [删除测试数据库]

  • Dropping test database...
    ERROR 1008 (HY000) at line 1: Can‘t drop database ‘test‘; database doesn‘t exist
    ... Failed! Not critical, keep moving...
  • 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? [Y/n] y [更新权限]
... Success!

All done! If you‘ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up...

第五部,使用新密码设置验证登录
用新的密码登录,修改MySQL表支持非本机连接:
[[email protected] ~]# mysql -u root –p123456
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> select host, user from user;
+-----------+-----------+
| host | user |
+-----------+-----------+
| localhost | mysql.sys |
| localhost | root |
+-----------+-----------+
2 rows in set (0.00 sec)

mysql> update user set host = ‘%‘ where user = ‘root‘;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select host, user from user;
+-----------+-----------+
| host | user |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
+-----------+-----------+
2 rows in set (0.00 sec)

mysql> flush privileges; ------刷新生效
Query OK, 0 rows affected (0.00 sec)
mysql>

原文地址:http://blog.51cto.com/372550/2061505

时间: 2024-10-10 06:13:04

Centos7环境MySQL安装简易方法的相关文章

CentOS7环境下安装VIM8 并支撑python3

CentOS7环境下安装VIM8并支撑python3 在CentOS7环境下打造pythonIDE的时候发现系统自带的vim因为版本低对python的支持不够,导致安装插件的时候总是出错,所以干脆把原系统中的vim删除后源码安装vim8并配置支持python3 删除系统中原有的vim yum -y remove vim* 利用yum命令将系统中的vim删除 源码安装vim 先进入你想放安装包的路径 cd /usr/local/share 我这里就放在了这个路径下,你们视情况而定 下载vim源码包

centos7下mysql安装--韩国庆

首先我先给大家介绍下MariaDB和mysql的区别. 上图,"MySQL之父"的骨灰级程序员Monty,但是mysql被Oracle收购后,Monty又开始去发展另一条数据库的道路,并且以Monty的女儿名称Maria命名了MariaDB,在centos7中yum中有MariaDB,但是找不到mysql数据库.事实,MariaDB是mysql另一个身份,mysql中的sql和命令都可以在MariaDB中使用.但是一些老技术人员能还是喜欢使用mysql,并且公司也会要求使用mysql,

CentOS7下mysql安装

CentOS7下安装MySQL --下载mysql http://mirrors.sohu.com/mysql/MySQL-5.6/ http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar 一.准备工作 --下载后文件 MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar --新建文件夹 mkdir /home/www/

Centos7环境下安装Mysql5.7版本

实验环境: VMware Workstation12 Centos-7-x86_64系统(ip地址:192.168.5.132)(2G内存 2个处理器) 使用软件:boost_1_59_0.mysql-5.7.17 [百度网盘](https://pan.baidu.com/s/1sKubgwvM1Ft6_XdkqzzbDQ) 实验开始 1.安装实验环境 yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake创建一个目录文件将软件包

linux 环境下安装oracle11g方法及安装过程中遇上的问题解决方法

 Oralce安装教程 1.先安装需要的依赖包 找到哪个没有安装,直接yum install XX,直到所有的都安装完成.注意,可能一个包安装了,再次执行检查,还是提示没有安装,那么就不需要管他们了,继续安装下面的. rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-deve

添加Python环境变量的简易方法

如果安装的时候没有选择Add Python.exe to Path导致在命令提示符下执行python 提示 'python' 不是内部或外部命令,也不是可运行的程序或批处理文件.可以通过 如下两种方法:方法一:使用cmd命令添加path环境变量 在cmd下输入: path=%path%;D:\Python27 接着按"Enter"回车键. 其中: D:\Python27 是Python的安装目录. 方法二:在环境变量中添加Python目录 (1) 右键点击"计算机"

linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦

一.Linux下安装MySQL 1.下载 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads下载版本:我这里选择的5.6.33,通用版,linux下64位也可以直接复制64位的下载地址,通过命令下载:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz 2.卸载老版本MySQL find / -na

VS2010+WDK开发环境搭建最简易方法

这是目前编译驱动程序,开发驱动程序最方便.最亲切.最自然的方法. 1.制作一个文本文件,(名称如:wdkproperty.props) 2.放入你的project目录内, 3.在property manager中加入这个wdkproperty.props,项目即可直接编译成功,.sys文件出来了. 4.自动区分debug,release版本,注意生成目录路径. 5.注意:我的WDK安装在D:\DDK7600 wdkproperty.props 1 <?xml version="1.0&qu

Linux Centos7中MySql安装

(1)     安装Mysql5.7: 执行命令:rpm -ivh http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-release-el7-7.noarch.rpm 执行命令:yum install mysql-community-server (2)     配置Mysql开机自动启动 执行命令:systemctl enable mysqld (3)     启动MYSQL: 执行命令:syst