博客参考:  https://www.cnblogs.com/pyyu/p/9467289.html

1. Mysql安装

、首先在 RHEL/CentOS 和 Fedora 操作系统中添加 MariaDB 的 YUM 配置文件 MariaDB.repo 文件。

#编辑创建mariadb.repo仓库文件
vi /etc/yum.repos.d/MariaDB.repo
、添加repo仓库配置
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=
、当 MariaDB 仓库地址添加好后,你可以通过下面的一行命令轻松安装 MariaDB。

yum install MariaDB-server MariaDB-client -y
.
mariadb数据库的相关命令是: systemctl start mariadb #启动MariaDB systemctl stop mariadb #停止MariaDB systemctl restart mariadb #重启MariaDB systemctl enable mariadb #设置开机启动
. 启动后正常使用的mysql
systemctl start mariadb

2. 初始化mysql

在确认 MariaDB 数据库软件程序安装完毕并成功启动后请不要立即使用。为了确保数据 库的安全性和正常运转,需要先对数据库程序进行初始化操作。这个初始化操作涉及下面  个 步骤。
➢ 设置 root 管理员在数据库中的密码值(注意,该密码并非 root 管理员在系统中的密 码,这里的密码值默认应该为空,可直接按回车键)。
➢ 设置 root 管理员在数据库中的专有密码。
➢ 随后删除匿名账户,并使用 root 管理员从远程登录数据库,以确保数据库上运行的业
务的安全性。
➢ 删除默认的测试数据库,取消测试数据库的一系列访问权限。
➢ 刷新授权列表,让初始化的设定立即生效。
mysql_secure_installation

3. MySql基本命令

#修改mysql密码
MariaDB [(none)]> set password = PASSWORD('redhat123');
登录mysql

[root@VM_0_2_centos yum.repos.d]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.1.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> Ctrl-C -- exit!
Aborted
[root@VM_0_2_centos yum.repos.d]#

设置mysql

.中文编码设置,编辑mysql配置文件/etc/my.cnf,下入以下内容

[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
log-error=/var/log/mysqld.log
bind-address = 0.0.0.0 #允许远端所有机器访问

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
.授权配置

远程连接设置哦设置所有库,所有表的所有权限,赋值权限给所有ip地址的root用户
mysql > grant all privileges on *.* to root@'%' identified by 'password'; 远端访问必须有此命令
#创建用户
mysql > create user 'username'@'%' identified by 'password';
#刷新权限
flush privileges;

数据库备份与恢复

mysqldump命令用于备份数据库数据

[root@master ~]# mysqldump -u root -p --all-databases > /tmp/db.dump
进入mariadb数据库,删除一个db [root@master ~]# mysql -uroot -p MariaDB [(none)]> drop database s11;
进行数据恢复,吧刚才重定向备份的数据库文件导入到mysql中 [root@master ~]# mysql -uroot -p < /tmp/db.dump

Mysql 主从复制

bind-address = 0.0.0.0

最新文章

  1. Fedora 22中的用户和用户组管理
  2. JS 字符串
  3. 使用Source Safe for SQL Server解决数据库版本管理问题
  4. BZOJ1816 [Cqoi2010]扑克牌
  5. Memcached原理深度分析详解
  6. drupal 2016-11-3
  7. 3.SQL*Plus命令
  8. java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.getTempDirectory()Ljava/io/File;
  9. 浏览器兼容汇总(css+js)
  10. Mybatis源码分析-StatementHandler
  11. Linux shell查询ip归属地
  12. 4、json-server的使用
  13. monkey Test 环境配置
  14. N皇后问题(DFS)
  15. expect远程登录服务器并执行命令
  16. Vue中的事件与常见的问题处理
  17. SharePoint Designer 配置工作流后需要重启的问题
  18. Hash索引和BTree索引
  19. vs快捷键代码格式化或代码对齐名字
  20. 测试下markdown!

热门文章

  1. session以及分布式服务器session共享
  2. YAML教程
  3. Bioconductor简介
  4. 解决 cmake_symlink_library: System Error: Operation not supported
  5. 2017年值得一看的7个APP设计
  6. 【Linux】目录文件权限的查看和修改【转】
  7. C语言基础第二次作业
  8. 文件权限命令 linux
  9. (KMP 模板)Number Sequence -- Hdu -- 1711
  10. Hdu2952 Counting Sheep 2017-01-18 14:56 44人阅读 评论(0) 收藏