博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos yum mysql 5.6_centos7 yum方式安装 mysql5.6版本数据库
阅读量:4963 次
发布时间:2019-06-12

本文共 3416 字,大约阅读时间需要 11 分钟。

edf785913ea463b60ad5cee71bf53317.png

注:出这个版本的安装方式使用因为  centos自带mariadb

其实yum方式安装是可以不用删除mariadb的,安装MySQL会覆盖掉之前已存在的mariadb

1:下载源文件

wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

2:判断当前centos系统中是否有已存在的mysql,有则卸载即可

yum list installed | grep mysql

#删除系统自带的mysql

yum -y remove mysql-libs.x86_64

#卸载后再用全局查找,查找出残留的文件等信息,继续删除

find / -name mysql

#rm -rf 自行删除查询出来的目录,若没有则无需删除

由于这个mysql的yum源服务器在国外,所以下载速度会比较慢,mysql5.6只有79M大,而mysql5.7就有182M。(其实就是你服务器垃圾,没别的)

3:安装mysql-community-release-el7-5.noarch.rpm包

rpm -ivh mysql57-community-release-el7-7.noarch.rpm

安装完这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo

24e2bfbb9ed2184c8af095f67a3d9b5d.png

#进入/etc/yum.repos.d/

cd /etc/yum.repos.d/

vim mysql-community.repo

eb671843f617bdbbb2d57ca6e0e141ff.png

用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件

yum repolist all | grep mysql

b690e4a56d1c52ef805a3e5ed06730fb.png

yum install mysql-server -y

6793f8de1b01fda93872ddd39bde6fba.png

# 加入开机自启动

systemctl enable mysqld

# 启动mysql服务进程

systemctl start mysqld

# 查看mysql服务进程

systemctl status mysqld

a8cb085eaab3ffdaa1143268ca870179.png

4:安装完毕后 mysql会生成一个随机密码 命令查看:

cat /var/log/mysqld.log |grep password

e0c52739d0dc6d84f4ed7db59fb0e4e5.png

5:查看是否可以用密码登录:

mysql -uroot -p?j/6P-ou#D<1

0d28f1a74ed569c9c798dfbbd1bc6c30.png

6:初始化数据库(请注意如下设置)

mysql_secure_installation

[root@localhost ~]# 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 #是否删除test数据库

- 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...

6:远程连接mysql、Navicat等工具连接的时候、就是远程连接、而不是登陆的账号密码了。

若远程连接账号密码都是对的、但是连接不上、可能就是防火墙没有添加3306端口、添加上就OK了

配置:

登陆mysql

mysql>use mysql;

mysql>GRANT ALL PRIVILEGES ON *.* TO "myuser"@"%" IDENTIFIED BY "mypassword" WITH GRANT OPTION;

mysql> flush privileges;

mysql> exit;

转载地址:http://xqqhp.baihongyu.com/

你可能感兴趣的文章
Docker 运维高级应用管理
查看>>
AJAX与Jqurey实现AJAX
查看>>
常用正则表达式大全——包括校验数字、字符、一些特殊的需求等等
查看>>
APP性能测试指标
查看>>
hadoop集群管理之 SecondaryNameNode和NameNode
查看>>
bzoj2733: [HNOI2012]永无乡
查看>>
协方差矩阵计算方法
查看>>
获取Linux时间函数
查看>>
scala的type alias特性
查看>>
PCL 3维点云的模板匹配
查看>>
java XML解析成Map
查看>>
[bzoj1014][JSOI2008]火星人prefix
查看>>
1010 Radix:猥琐的测试数据
查看>>
JavaScript中函数和构造函数的区别
查看>>
数据结构学习(四) Java链表实现
查看>>
Hitachi Content Platform学习
查看>>
kubernetes1.3搭建dns服务
查看>>
【性能调优】一次关于慢查询及FGC频繁的调优经历
查看>>
Swift单例
查看>>
Qt之C语言类型typedef a[]等
查看>>