一、mysql_install_db说明

当MySQL的系统库(mysql系统库)发生故障或需要新加一个mysql实例时,需要初始化mysql数据库。

需要使用的命令:/usr/local/mysql/bin/mysql_install_db

#/usr/local/mysql/bin/mysql_install_db --help 可以查看帮助信息如下

Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS]

--basedir=path       The path to the MySQL installation directory.

--cross-bootstrap    For internal use.  Used when building the MySQL system

tables on a different host than the target.

--datadir=path       The path to the MySQL data directory.

--force              Causes mysql_install_db to run even if DNS does not

work.  In that case, grant table entries that normally

use hostnames will use IP addresses.

--ldata=path         The path to the MySQL data directory.

--rpm                For internal use.  This option is used by RPM files

during the MySQL installation process.

--skip-name-resolve  Use IP addresses rather than hostnames when creating

grant table entries.  This option can be useful if

your DNS does not work.

--srcdir=path        For internal use.  The directory under which

mysql_install_db looks for support files such as the

error message file and the file for popoulating the

help tables.

--user=user_name     The login username to use for running mysqld.  Files

and directories created by mysqld will be owned by this

user.  You must be root to use this option.  By default

mysqld runs using your current login name and files and

directories that it creates will be owned by you.

All other options are passed to the mysqld program

除了支持以上的参数,还支持mysqld的参数。

二、举例:

本文以新加一个mysql实例为例。例如服务器上已经安装了3306端口的mysql服务,需要再启一个3308端口的mysql服务。

假设mysql安装在/usr/local/mysql路径下,找一个磁盘空间剩余比较大的盘,如/data1,把3308端口的mysql的数据保存在/data1下

#mkdir /data1/mysql_3308

#mkdir /data1/mysql_3308/data

#chown -R mysql:mysql /data1/mysql_3308

复制一个mysql配置文件my.cnf到/data1/mysql_3308目录下

#vi /data1/mysql_3308/my.cnf

修改配置文件,将端口和相关目录的都改为新的设置,如下:

[client]

character-set-server = utf8

port    = 3308

socket  = /tmp/mysql_3308.sock

[mysqld]

user    = mysql

port    = 3308

socket  = /tmp/mysql_3308.sock

basedir = /usr/local/mysql

datadir = /data1/mysql_3308/data

log-error = /data1/mysql_3308/mysql_error.log

pid-file = /data1/mysql_3308/mysql.pid

......其他略

确保配置文件无误。

运行下面命令进行数据库的初始化:

#/usr/local/mysql/bin/mysql_install_db --defaults-file=/data1/mysql_3308/my.cnf --datadir=/data1/mysql_3308/data

完成后新的3308数据库就初始化好了,如果有报错,则按照报错的提示查看报错日志,一般情况下都是my.cnf配置文件的问题,修正后即可。

三、启动新mysql

启动3308端口的mysql服务

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/data1/mysql_3309/my.cnf &

检查是否启动

#ps aux|grep mysql

如果有3308字样说明已经启动成功

可将启动命令加入/etc/rc.local随服务器启动

新加的mysql没有设置root密码,可以通过下面命令设置root密码:

#/usr/local/mysql/bin/mysqladmin -S /tmp/mysql_3308.sock -u root password 'new-password'

注意:whereis mysql 查看自己具体数据库安装位置(usr/lib/mysql_install_db)

my.cnf 查看自己数据库存放位置(suse: /etc/my.conf)

linux初始mysql_linux mysql初始化相关推荐

  1. linux下安装mysql初始化报错:bin/mysqld: error while loading shared libraries: libnuma.so.1

    如果安装mysql出现了以上的报错信息.这是缺少numactl的问题. Centos7使用yum -y install numactl就可以解决这个问题了. ubuntu使用sudo apt-get ...

  2. Linux服务器Mysql初始化

    一.安装MySql 下载MySql 通过XShell连接Linux服务器 通过XFTP将文件上传到Linux服务器上 #编辑mysql初始化文件 $ vim /etc/my.cnf #在文件最后一行添 ...

  3. linux centos7 mysql_Linux centos7环境下安装MySQL的步骤详解

    Linux centos7环境下安装MySQL的步骤详解 安装MySQL mysql 有两个跟windows不同的地方 1).my.ini 保存到/etc/my.ini 2).用户权限,单独用户执行 ...

  4. linux启动mysql_Linux服务器安装Mysql教程

    最开始用服务器的时候,也是对这些环境的安装操作极其陌生,找了很多方式,写这边文章就是为了让更少的童鞋走弯路,下面我们看看具体的操作流程. 1.首先关闭linux的防火墙,执行命令 chkconfig ...

  5. linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案

    linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案 参考文章: (1)linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案 (2) ...

  6. linux 重庆mysql_Linux服务器上MYSQL的安装

    Linux服务器上MYSQL的安装 更新时间:2020-07-21 14:48:42点击次数:556次 移除CentOS默认的mysql-libs,执行下列语句: yum remove mysql-l ...

  7. linux启动mysql_Linux安装mysql

    安装包下载 前往mysql官网下载安装包: https://downloads.mysql.com/archives/community/ 将安装包上传服务器并解压 tar -xvf mysql-5. ...

  8. linux下安装mysql的方式_linux下安装mysql的两种方式

    linux下安装mysql的两种方式 1 源码安装 1 创建mysql用户: useradd mysql passwd mysql 2 解压缩下载的mysql包: tar -zxvf mysql-5. ...

  9. linux mysql编译安装mysql_【MySQL安装】Linux下安装MySQL(预编译)

    预编译方式安装MySQL 一.环境说明 操作系统:Redhat Linux 7.2 MySQL版本:5.7 安装介质:mysql-5.7.25-linux-glibc2.12-x86_64.tar.g ...

最新文章

  1. lodoop打印控件详解
  2. 博途上载hmi程序_西门子HMI触摸屏(精智面板)恢复出厂设置方法
  3. Spring配置文件约束头
  4. AI+大数据顶级技术盛会倒计时10天,6.6折票限时特惠!
  5. python中tensorflow_TensorFlow入门教程TensorFlow 基本使用T
  6. Gallery of Processor Cache Effects
  7. 结对编程之设计电梯控制程序
  8. java刷票小程序,小程序投票系统刷票
  9. 魔兽世界怀旧服正式服风铃键盘鼠标同步器TBC70级燃烧远征
  10. 云计算给IT产业结构带来的影响 .
  11. linux文件系统 ubi,UBI 文件系统移植 sys 设备信息
  12. 牛熊分界点?技术指标择时 在当前A股指数效果解密
  13. 数据结构-链表-环形链表
  14. python 工资条_当财务部的人会编程,会发生什么?Python实现自动化群发工资条...
  15. Android 开发者转型 “FrameWork”必不可少
  16. Android前端判断敏感词汇
  17. 华为又走在美国芯片企业前面,将率先发布5nm工艺芯片
  18. Put GridView inside ScrollView
  19. 由开启coredump引起的对shell的深入探究
  20. ARM 通用寄存器说明

热门文章

  1. 如何从一个美术变成程序员?
  2. 黑苹果仿冒CPU名称(装X专用模式)
  3. 视频教程-血腥大地-第三季(怪物模型制作)-其他
  4. python使用 requests 模块发送http请求
  5. 元旦插画素材|新年伊始,恭贺崭新2021,旭日东升!
  6. 8步安装多多客小程序全插件化1.0开源版
  7. Backbone 之 Inception:纵横交错 (Pytorch实现及代码解析
  8. Linux or QNX ?
  9. emacs 自带的简单入门教程
  10. 基于osgEarth搭建三维可视化平台 第3讲 加载高程数据