资讯

精准传达 • 有效沟通

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

mysql怎么执行初始化,mysql安装初始化

如何初始化MySQL数据库在Ubuntu安装后

当在Ubuntu中执行命令sudo apt-get install mysql-server5.1安装的时候居然没有提示我输入mysql的密码之类的信息,但是当安装好之后再终端中直接输入mysql的时候又能直接进入mysql中,虽然可以进入mysql中但是我对mysql的密码一点都不知道,所以这个时候安装的mysql就相当于没有安装,因为不能用程序进行操作mysql数据库(因为操作数据库都需要mysql数据的密码的),为了解决ubuntu中mysql密码初始化的方法有一下两种:

成都创新互联主要从事网站设计、做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务下陆,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

(1)打开/etc/mysql/debian.cnf文件,在这个文件中有系统默认给我们分配的用户名和密码,通过这个密码就可以直接对mysql进行操作了。但是一般这个密码都比较怪,很长很长。

(2)当进入mysql之后修改mysql的密码:这个方法比较好,具体的操作如下用命令:set password for 'root'@'localhost' = password('yourpass');当修改之后就可应正常对mysql进行操作了。

sql数据库数据如何初始化

初始化mysql数据库,在shell中运行以下命令:

cd /usr/local/mysql

mkdir sock

cd /usr/local/mysql/bin

初始化数据库

./mysql_install_db--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

或者# mysqld --initialize

如何初始化MySQL数据库

1、停止mysql服务

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

3、重启myql即可

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

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

centos mysql 怎么初始化

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

若不加任何参数,则该命令按照/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.

如何初始化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'

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/dsccppp.html
多年建站经验

多一份参考,总有益处

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

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

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