设为首页 收藏本站
查看: 896|回复: 0

[经验分享] 二进制格式安装MySQL

[复制链接]

尚未签到

发表于 2018-10-6 09:30:40 | 显示全部楼层 |阅读模式
  已经编译进行过编译的软件包,下载到本机直接解压到特定的目录下就可以使用的格式.
  1.查询本地是否安装mysql数据库相关的软件包(卸载之)
  rpm -qa "mysql*"   (centos6)
  rpm -qa "mariaDB*" (cetos7)
  2.mariadb.org下载源码二进制包带有linux字样的已经编译过的包:
  mariadb-10.2.12-linux-x86_64.tar.gz(大小440M左右因为已经编译过)
  3. 准备用户
  getent passwd mysql  查询passwd是否有mysql用户
  useradd -r mysql -s /sbin/nologin  创建mysql系统用户
  [root@centos7 ~ 13]#id mysql
  uid=990(mysql) gid=305(mysql) groups=305(mysql)
  生产环境建议置后一个版本至少.
  4.解压mariadb-10.2.12-linux-x86_64.tar.gz
  4-1. tar xvf  mariadb-10.2.12-linux-x86_64.tar.gz -C /usr/local/
  注意:解压目录指定,因为这是已经编译过的源码包所以路径很重要需要解压到/usr/local/下
  4-2.需要改名因为编译之前的目录叫mysql;
  建议创建软连接:
  ln -s mariadb-10.2.12-linux-x86_64/ mysql
  5.修改文件权限默认没有属主属组:(可以不做修改)
  chown -R mysql.mysql mysql/
  6.导出环境变量:
  echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
  cat /etc/profile.d/mysql.sh
  . /etc/profile.d/mysql.sh (重读配置文件)
  7.准备数据目录;建议使用逻辑卷
  7-1.创建逻辑卷:
  fdiak /dev/sda
  7-2.同步磁盘:
  partprobe (6 使用pertx)
  7-3.创建PV物理卷:
  pvcreate /dev/sda6
  7-4. 创建卷组:
  vgcreate vg0-mysqldata /dev/sda6 -s 16M
  7-5.查看卷组:
  vgdisplay
  7-6.创建LVM
  lvcreate -n lv_mysqldata -l 100%FREE vg0mysqldata
  7-7.创建逻辑卷的文件系统:
  mkfs.xfs /dev/vg0mysqldata/lv_mysqldata
  8.创建挂载点并且挂载添加/etc/fstab条目(请注意当前所在的工作目录.我当前的路径是在/usr/local/mysql/bin)
  mkdir -pv /data/mysqldb
  echo ' UUID=98833275-08ee-446f-b888-3e03557deedf /data/mysqldb xfs defaults 0  0' >> /etc/fstab (建议别这么添加清空了这个文件就尴尬了)
  mount -a 重读/etc/fsatb
  9.这连个就是mysql的数据库目录了安全起见建议修改权限为770
  chmod 770 /data/mysqldb/
  10.初始化数据库:
  cd scripts/
  scripts/mysql_install_db --datadir=/data/mysqldb --user=mysql
  注意:这个脚本一定要在它的上一级目录执行否则会报错
  11.由于默认的配置文件过于简陋而且数据库路径也不对,可参考/usr/local/mysql/support-files/目录下以.cnf结尾的模版配置文件.
  11-1.cp my-huge.cnf /etc/my.cnf (覆盖目标文件)
  修改如下:
  12.运行/usr/local/mysql/mysql-server 服务脚本
  cp mysql.server /etc/init.d/mysqld 复制并改名mysqld
  chkconfig --add mysqld   添加到系统脚本开机启动
  13.启动服务:
  service mysqld start
  源码安装结束
  14.查看是否有错误信息
  15.查看端口3306
  ss -tnl
  16.mysql安装完成默认没有密码需要运行一个安全脚本:
  . /mysql_secure_installation (交互式设置密码及删除匿名用户)
  [root@centos7 /usr/local/mysql/bin 178]# ./mysql_secure_installation
  NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
  SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
  In order to log into MariaDB to secure it, we'll need the current
  password for the root user.  If you've just installed MariaDB, 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): 输入root旧口令(没有直接回车)
  OK, successfully used password, moving on...
  Setting the root password ensures that nobody can log into the MariaDB
  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 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.
  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, 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  是否删除test测试数据库(随机附带的测试数据库)
  - 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!
  启动服务:
  service mysqld start
  本地安装mysql的Mysql-client 命令行测试连接


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-613535-1-1.html 上篇帖子: phpmyadmin+mysql-5.6.16.tar.gz使用 下篇帖子: MySQL数据类型+简单操作
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表