当前位置: 首页 > news >正文

企业安全文化建设中的安全承诺是指/搜索排名优化

企业安全文化建设中的安全承诺是指,搜索排名优化,wordpress虚拟资源交易平台,公司网站域名实名认证怎么做场景 若mysql 安装初步使用rpm默认将db安装到/var/lib/mysql/路径后,想更改db(datadir)路径,怎么处理呢? 网站参考了很多,实验没有成功,看到有提SELinux的,研究了一下果然如此。现整理总结了一下&#xff…

场景

若mysql 安装初步使用rpm默认将db安装到/var/lib/mysql/路径后,想更改db(datadir)路径,怎么处理呢? 网站参考了很多,实验没有成功,看到有提SELinux的,研究了一下果然如此。现整理总结了一下,仅供参考。

测试整理步骤说明

  • 简单安装步骤
  • 更改db目录的2中方式

注意:

修改datadir,要Linux要关闭SELinux(参看附录)。有的文章说要关闭iptables,测试是不需要的。

(1)通过db初始化命令更改db存放位置:
/usr/bin/mysql_install_db --user=mysql --basedir=/usr/ --datadir=/data/public3306/db/

(2)通过将原来db目录内内容拷贝到新地址,再更改my.cnf 文件的datadir (类似oracle 冷备,更改控制文件 datafile指针…)

  • 卸载环境

一、安装步骤

--> 准备安装包
[root@lottery ~]# ll  
-rw-rw-rw-  1 root root  18360416 5月  19 10:54 MySQL-client-5.6.19-1.el6.x86_64.rpm
-rw-rw-rw-  1 root root  54592892 5月  19 10:54 MySQL-server-5.6.19-1.el6.x86_64.rpm
-->rpm -vhi 安装包
[root@lottery ~]# rpm -hvi MySQL-client-5.6.19-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]1:MySQL-client      ########################################### [100%] 
[root@lottery ~]# rpm -hvi MySQL-server-5.6.19-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]1:MySQL-server     ########################################### [100%]
-->启动mysql服务
[root@lottery ~]#  /etc/init.d/mysql start
Starting MySQL... SUCCESS!
-->初始化密码
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -uroot
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit 
# /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password:
mysql>   show variables like '%datadir%';
+---------------+-----------------------+
| Variable_name | Value                           |
+---------------+-----------------------+
| datadir             | /var/lib/mysql/           |
+---------------+-----------------------+

这里命令可以使用“/etc/init.d/mysql start|stop|restart”,也可以使用“service mysql start|stop|restart”;

二、更改db目录的2中方式

通过db初始化命令更改db存放位置

/usr/bin/mysql_install_db --user=mysql --basedir=/usr/ --datadir=/data/public3306/db/

  • vim /etc/my.cnf

    user=mysql #必须有

    datadir=/usun/mysql/data #必须有

    log-error=/hskj/mysql/data/error.log

    pid-file=/hskj/mysql/data/mysql.pid

  • 将之前数据库停掉–用mysql_install_db 脚本 初始化(新建库)到/data/public3306/db/ 目录的数据库…
  • 若原数据库有新建的database,需要将database对应的目录cp -rp 到更改后的路径/data/public3306/db/ ;
  • 否则原新的database不会在新路径体现…
[root@lottery public3306]# /usr/bin/mysql_install_db --user=mysql --basedir=/usr/ --datadir=/data/public3306/db/
Installing MySQL system tables...OK
Filling help tables...OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:/usr//bin/mysqladmin -u root password 'new-password'/usr//bin/mysqladmin -u root -h lottery password 'new-password'
Alternatively you can run:/usr//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:cd /usr ; /usr//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.plcd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web athttp://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr//my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr//my-new.cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@lottery public3306]#  /etc/init.d/mysql start
Starting MySQL.... SUCCESS! 
[root@lottery public3306]# cd db
[root@lottery db]# ll
总用量 2097172
-rw-rw---- 1 mysql mysql         56 5月  19 15:47 auto.cnf 
drwx------ 2 mysql mysql       4096 5月  19 15:46 mysql
drwx------ 2 mysql mysql       4096 5月  19 15:46 performance_schema
drwx------ 2 mysql mysql       4096 5月  19 15:46 test
[root@lottery db]# 

通过将原来db目录内内容拷贝到新地址,再更改my.cnf 文件的datadir

  • 测试之前将原database,执行create database lottery ,利于迁移后是否正确.
--> 原路径
[root@lottery mysql]# pwd
/var/lib/mysql/ 
--> 目录开头的为database
[root@lottery mysql]# ll 
-rw-rw---- 1 mysql mysql         56 5月  19 15:47 auto.cnf 
drwx------ 2 mysql mysql       4096 5月  19 15:52 lottery
drwx------ 2 mysql mysql       4096 5月  19 15:46 mysql
drwx------ 2 mysql mysql       4096 5月  19 15:46 performance_schema
drwx------ 2 mysql mysql       4096 5月  19 15:46 test 
--> 查看lottery 数据库的表
[root@lottery lottery]# ll  lottery/*
-rw-rw---- 1 mysql mysql    54 5月  19 15:47 db.opt
-rw-rw---- 1 mysql mysql  8560 5月  19 15:52 t1.frm    ---t1表 一张
-rw-rw---- 1 mysql mysql 98304 5月  19 15:52 t1.ibd
--> 创建新datadir目录
[root@lottery lottery ]# mkdir -p /data/public3306/db --  参数-p: 级联创建
--> 整个mysql datadir进行拷贝
[root@lottery lottery ]# cp -pr /var/lib/mysql/ /data/public3306/db --  参数-p:连带属性拷贝,-r是目录拷贝
--> 检查cp 的文件内容
[root@lottery lottery  ]# cd /data/public3306/db 
[root@lottery db]# ll
-rw-rw---- 1 mysql mysql         56 5月  19 15:47 auto.cnf 
drwx------ 2 mysql mysql       4096 5月  19 15:52 lottery
drwx------ 2 mysql mysql       4096 5月  19 15:46 mysql
drwx------ 2 mysql mysql       4096 5月  19 15:46 performance_schema
drwx------ 2 mysql mysql       4096 5月  19 15:46 test 
--> 更改my.cnf 的datadir参数,将原来的/var/lib/mysql 改成 /data/public3306/db 
[root@lottery db]# vi /etc/my.cnf
--> 启动mysql服务
[root@lottery db]# /etc/init.d/mysql start
Starting MySQL..... SUCCESS!--> 查看更改后datadir是否有效的2种方式
--> OS层查看
[root@lottery db]# ps -ef | grep mysql 
root     11346     1  0 16:07 pts/6    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/data/public3306/db --pid-file=/data/public3306/mysqld.pid
mysql    12007 11346 17 16:07 pts/6    00:00:03 /usr/sbin/mysqld --basedir=/usr --datadir=/data/public3306/db --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/data/public3306/err.log --pid-file=/data/public3306/mysqld.pid --socket=/data/public3306/mysql.sock --port=3306 
--> DB层查看  
mysql> show variables like '%datadir%';
+---------------+-----------------------+
| Variable_name | Value                 |
+---------------+-----------------------+
| datadir            | /data/public3306/db/ |
+---------------+-----------------------+ mysql>--> 检查下原来database lottery 中的t1表 再新的环境中是否存在
mysql> use lottery;
Database changed 
mysql> show tables;
+-------------------+
| Tables_in_lottery |
+-------------------+
| t1                |
+-------------------+ 
mysql>

卸载环境

--> 查看系统中是否以rpm包安装的mysql
[root@lottery db]# rpm -qa | grep -i mysql
MySQL-client-5.6.19-1.el6.x86_64
MySQL-server-5.6.19-1.el6.x86_64
--> 通过rpm -e 卸载软件包
[root@lottery db]# rpm -e MySQL-client-5.6.19-1.el6.x86_64
[root@lottery db]# rpm -e MySQL-server-5.6.19-1.el6.x86_64
--> 查看是否有mysql服务,删除 mysql服务命令:chkconfig --del mysql
[root@lottery db]# chkconfig --list | grep -i mysql
--> mysql程序命令进行删除 
[root@lottery db]# whereis mysql 
mysql: /usr/lib64/mysql
[root@lottery db]# rm  -rf /usr/lib64/mysql

附录:SELinux

安全增强型 Linux(Security-Enhanced Linux)简称 SELinux,它是一个 Linux 内核模块,也是 Linux 的一个安全子系统。SELinux 的结构及配置非常复杂,而且有大量概念性的东西,要学精难度较大。很多 Linux 系统管理员嫌麻烦都把 SELinux 关闭了。

查看使用:

# getenforce

一般会返回三种状态:

  • Enforcing (记录警告且阻止可疑行为)
  • Permissive (代表仅记录安全警告但不阻止可疑行为)
  • Disabled (禁用状态)

也可使用以下命令查看状态:

/usr/sbin/sestatus -v

若SELinux status: enabled 则表示SELinux是开启状态。

临时关闭,重启机器后恢复原状态:

setenforce 0 #设置SELinux成为permissive模式

(setenforce 1 #设置SELinux 成为enforcing模式)

永久改变 SELinux 状态:

  • #vim /etc/sysconfig/selinux
    -将SELINUX=enforcing,改为SELINUX=disabled

  • #shutdown -r now -重新启动

  • #getenforce -查看返回Disabled。

主从同步

配置简单,参考这一篇文章即可:
https://blog.csdn.net/weixin_44187730/article/details/85706686#3_10

常用命令

  • 创建用户:allowsalve,密码为:147258,并授权。

GRANT REPLICATION SLAVE ON . TO ‘allowsalve’@‘192.168.44.%’ IDENTIFIED BY ‘147258’;

#刷新用户权限

flush privileges;

  • 查询用户和授权

select host,user,authentication_string from mysql.user;

  • 从库链接主服务器命令

stop slave

CHANGE MASTER TO
MASTER_HOST=‘192.168.44.125’,
MASTER_USER=‘allowsalve’,
MASTER_PASSWORD=‘147258’,
MASTER_LOG_FILE=‘mysql-bin.000011’,
MASTER_LOG_POS=247;

start slave

#主节点(master)
show master status;

#从节点(slave)
show slave status\G;[可以看主从同步的问题]

参考:
https://jingyan.baidu.com/article/020278115258441bcd9ce57e.html

https://yq.aliyun.com/articles/52238

http://blog.itpub.net/22390488/viewspace-2122857/

臭味相投的朋友们,我在这里:

猿in小站:http://www.yuanin.net

csdn博客:https://blog.csdn.net/jiabeis

简书:https://www.jianshu.com/u/4cb7d664ec4b

微信免费订阅号“猿in”
猿in

http://www.lbrq.cn/news/1031743.html

相关文章:

  • 上海建筑建材业网站办理大厅/网络平台
  • 网站建设合同审批/应用市场
  • 美国做旅游网站/个人网页模板
  • 小企业网站建设有什么用/世界球队最新排名榜
  • 个人网站 推荐/网站推广软件有哪些
  • 科学城做网站公司/互联网营销师是哪个部门发证
  • 新网站建设方案ppt/平台网站开发公司
  • b2b电子商务网站分类/图片外链生成器
  • 网站的二级页面怎么做代码/中国培训网官网
  • 电子商务网站建设与维护/免费发布信息的平台
  • 网站建设优化及推广/互联网广告推广是什么
  • 网站商城系统建设/桂林seo
  • 国外网站拼邮需要怎么做/广告免费发布信息平台
  • wordpress上传Flickr/seo3的空间构型
  • 中国建设银行联行号查询网站/百度网站流量查询
  • 网站建设功能需求/中国站长素材网
  • 网站怎么建立会员/百度seo是什么意思
  • 网站链接如何做二维码/北京网络营销咨询公司
  • 网站开发实验报告/营销策划与运营团队
  • 杭州市建设工程公示网站/百度上怎么发布信息啊
  • 做网站互联互通/百度人工客服24小时电话
  • 360网站地图怎么做/竞价推广工作内容
  • 无锡 做网站/设计素材网站
  • 网站升级正在升级维护/百度快照推广有效果吗
  • 怎么做免费公司网站/黑帽seo技术有哪些
  • 百度联盟广告点击一次收益/厦门seo百度快照优化
  • 怎么做直播网站的超管/郑州网站建设公司排名
  • 做网站的需求清单/如何制作网页最简单的方法
  • 日照网站开发建设/杭州网络优化公司排名
  • 扬州建设机械网站/如何去推广自己的产品
  • EN 61010电子电气设备安全要求标准
  • 【数据分享】351个地级市农业相关数据(2013-2022)-有缺失值
  • [AI React Web] 包与依赖管理 | `axios`库 | `framer-motion`库
  • w481社区老人健康信息管理系统的设计与实现
  • 【图像算法 - 13】基于 YOLO12 与 OpenCV 的实时目标点击跟踪系统(系统介绍 + 源码详细)
  • Android 项目:画图白板APP开发(一)——曲线优化、颜色、粗细、透明度