资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

mysql初始化怎么设置 mysql安装初始化

centos mysql 怎么初始化

使用的命令:mysql_install_db,用于初始化mysql的数据库,生成元数据。

创新互联建站专注于企业营销型网站建设、网站重做改版、织金网站定制设计、自适应品牌网站建设、H5页面制作成都商城网站开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为织金等各大城市提供网站开发制作服务。

若不加任何参数,则该命令按照/etc/my.cnf文件配置执行初始化工作,否则可参照如下帮助手动执行参数。

$ 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.

win10初始化mysql失败?

mysql安装步骤win10:

1、双击mysql-installer-community-5.7.20.0.msi安装包;

2、勾选 Iaccept the license terms,点击Next按钮;

3、选择Server only,点击Next选项(因为我只想安装个服务器端,所以选了这个选项。如果想安装所有的,请选择full选项,如果自定义安装请选择Custom选项);

4、点击Execute选项执行安装;

5、安装的过程中,在Progress列中可以看到安装进度;

6、status列变为Complete说明安装完成,点击Next按钮;

7、点击Next,进行产品配置;

8、这个保持默认选项,点击Next;

9、选择默认选项,Development Machine选项会使用最小的内存分配(因为是个人练习使用,所以不用占用太多电脑内存),点击Next;

10、设置root用户的口令(我这里设置的比较简单,所以提示密码比较弱,从安全的角度说,大家还是应该把密码设置的复杂一点),点击Next按钮;

11、默认配置,点击Next按钮;

12、插件和扩展这保持默认选项就好,点击Next按钮;

13、点击Execute按钮执行配置;

14、看到所有都是对号,说明配置成功,点击Finish按钮;

15、再点击Finish按钮完成安装;

16、点击开始菜单中的MySQL 5.7 Command Line Client 客户端;

17、输入安装时设置的root的口令,按下回车;

18、连接成功。

如何初始化mysql数据

一、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'

如何初始化MySQL数据库

1、停止mysql服务

2、删除mysql的data目录下的,除mysql这个目录外的其他目录(为保险期间,先移走)

3、重启myql即可

-----------------------------------

呵呵,放松,一切都会好起来的!

MySQL5.7数据库怎么初始化

从MSQL官中国下载MySQL服务器安装软件包,下面以mysql-installer-中国munity-5.7.3.0-m13.msi为例。 1、双击进入安装 2、在协议许可(License Agreement)界面,勾选“I accept the license terms”,点击“Next”。 3、在检查更新信息(Find latest products)界面,勾选“Skip the check for updates(no re中国mended)”跳过检查,然后点击“Next”。 4、在选择安装类型(Choosing a Setup Type)界面,根据安装需求选择安装类型(推荐默认开发版本),设置MySQL安装路径和数据存放路径,最后点击“Next”。 5、在检查要求(Check Requirements)界面,点击“Next”。 6、安装进度(Installation progress)界面,点击“Execute”执行。 7、等待安装进度完毕,点击“Next”。 8、进入配置概述(Configuration Overview)界面,点击“Next”。 9、在MySQL服务配置(MySQL Server Configuration)界面,默认不做修改,点击“Next”。 10、设置根账户(root账户)密码。 11、添加(非根)用户账户。其目的是便于数据库权限管理,为远程访问者提供安全账户。 12、默认windows服务配置不做修改,点击“Next”。 13、回到配置概述(Configuration Overview)界面,安装完毕点击“Next”。 14、MySQL安装完成(Installation Complete),点击“Finish”。 15、若勾选“安装后启动Mysql工作台”(Start Mysql Workbench after Setup),可见如下界面。 注意:MySQL环境变量配置。     在windows命令提示符中输入mysql,提示“mysql”不是内部或外部命令。只需将MySQL安装路径添加系统环境变量即可。     如安装路径为“D:\Program Files\MySQL”目录,则进入mysql server的bin目录下复制路径;其次在环境变量中编辑变量Path,变量值中输入“;”后粘贴“D:\Program Files\MySQL\MySQL Server 5.7\bin”路径,最后从新打开命令提示符窗口运行mysql即可


本文名称:mysql初始化怎么设置 mysql安装初始化
分享网址:http://cdkjz.cn/article/hijdcs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220