腾讯云 Centos 7 安装 MySql 2019/12/30安装成功

在腾讯云 CentOS 7中安装mysql

转载自:https://blog.csdn.net/weixin_43110416/article/details/90116614
https://www.cnblogs.com/ikel/p/8143996.html

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是
:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来	避开这个风险。
MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

1.卸载MariaDB数据库

> 1.先查看版本信息:
> rpm -qa | grep mariadb
> 2.如果有结果,直接删除,没有结果就不管他
> rpm -e --nodeps 版本信息   
> 3.没有提示信息,再次查找:
>  rpm -qa | grep mariadb

2.安装mysql

> 1.首先下载MySql的yum包
> wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
> 2.提示 Complete! 安装成功接下来安装MySql服务器
> yum -y install mysql-community-server
> 整个包有将近200MB网络不好的话需要等待一会儿,可以先去喝杯咖啡跟妹子聊聊天再回来。

3.启动mysql服务,并修改密码

#######启动mysql服务进程
[root@typecodes ~]# systemctl start mysqld 

#######配置mysql(设置密码等)
[root@typecodes ~]# 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] 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? [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...

4.设置远程登录

mysql>use mysql;
mysql> update user set host='%' where user='root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '填写root的密码' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql>SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
mysql>exit;
#service mysqld restart
这个是我的mysql版本:mysql-community-release-el7-5.noarch.rpm
序号1,2是引用的  https://blog.csdn.net/weixin_43110416/article/details/90116614
序号3,4是引用的  https://www.cnblogs.com/ikel/p/8143996.html
至于为什么拆开呢...... 
我这个台机子单独用哪个文档都搞不定...安装的版本也是没有默认密码的


在linux上安装mysql时找了许多的文章,也试了很多,弄完一天才发现CenterOS 7 默认不支持mysql了...
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值