centos 7安装mysql没有bin_Centos7安装Mysql(Mariadb)

一:安装方式

yum安装(配置yum源)

1- centos官方的yum源

#不同的yum源,软件包的名字也可能不一样,区分大小写 !!!!

2- 阿里云的yum源(下载速度快,但是版本较低)

安装命令如下:

(由于网速问题,我选择用阿里云的精简版)

yum install mariadb-server mariadb

3- mysql官方的yum源 (版本你自由去选择,下载较慢,文件完整性最好)

配置如下方式

1.找到yum仓库目录,创建repo文件

touch /etc/yum.repos.d/mariadb.repo

[root@bogon ~]# cd /etc/yum.repos.d

[root@bogon yum.repos.d]# ls

CentOS-Base.repo epel.repo repobak

[root@bogon yum.repos.d]# touch mariadb.repo

2.添加repo仓库配置 :写入如下内容,指定mysql官方的yum源

[root@bogon yum.repos.d]# vim mariadb.repo

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.1/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

3.此时yum会自动的加载这个repo文件,读取内容

4.下载mariadb数据库,服务端和客户端

yum install MariaDB-server MariaDB-client

# 或者

yum install MariaDB-server MariaDB-client -y

yum源就是配置在/etc/yum.repos.d/底下的*.repo文件而已

二:启动mariadb数据库

#启动MariaDB

systemctl start mariadb

# 启动以后 查看有没有mysql进程

ps -ef | grep mysql

# 查看mysql的网络信息

netstat -tunlp | grep 3306

[root@bogon yum.repos.d]# netstat -tunlp | grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 86177/mysqld

mysql -uroot -p

通过客户端连接数据库

mysql有哪些种类的客户端?

mysql -uroot -p

pymysql

navicat(可视化工具)

启动mariadb相关命令

mariadb数据库的相关命令是:

systemctl start mariadb #启动MariaDB

systemctl stop mariadb #停止MariaDB

systemctl restart mariadb #重启MariaDB

systemctl enable mariadb #设置开机启动

三:初始化mysql

3.1:详解

在确认 MariaDB 数据库软件程序安装完毕并成功启动后请不要立即使用。为了确保数据 库的安全性和正常运转,需要先对数据库程序进行初始化操作。这个初始化操作涉及下面 5 个 步骤。

➢ 设置 root 管理员在数据库中的密码值(注意,该密码并非 root 管理员在系统中的密 码,这里的密码值默认应该为空,可直接按回车键)。

➢ 设置 root 管理员在数据库中的专有密码。

➢ 随后删除匿名账户,并使用 root 管理员从远程登录数据库,以确保数据库上运行的业

务的安全性。

➢ 删除默认的测试数据库,取消测试数据库的一系列访问权限。

➢ 刷新授权列表,让初始化的设定立即生效。

确保mariadb服务器启动后,执行命令初始化

mysql_secure_installation

3.2:配置信息

# 默认回车

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 MariaDB

root user without the proper authorisation.

# 设置密码 123

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB 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.

#移出匿名用户 yes

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

... skipping.

By default, MariaDB 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...

... 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? [Y/n] y

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

3.3:配置信息图片

848ec1105b699d3b2c2e1255fa00f659.png

d992278fb52c7f21ca1c73c5487363fe.png

22ab01d28ff0929880fc4688d839de33.png

5f9444542de8807e3c662cc9b83cf2ba.png

8cbeaddcbd1c6b8735736c07ed724867.png

c05d6bf87a5009d24270487302845c3a.png<

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值