怎么將mysql初始化 mysql怎么初始化數(shù)據(jù)

MySQL5.7數(shù)據(jù)庫怎么初始化

從MSQL官中國下載MySQL服務(wù)器安裝軟件包,下面以mysql-installer-中國munity-5.7.3.0-m13.msi為例。 1、雙擊進(jìn)入安裝 2、在協(xié)議許可(License?Agreement)界面,勾選“I?accept?the?license?terms”,點(diǎn)擊“Next”。 3、在檢查更新信息(Find?latest?products)界面,勾選“Skip?the?check?for?updates(no?re中國mended)”跳過檢查,然后點(diǎn)擊“Next”。 4、在選擇安裝類型(Choosing?a?Setup?Type)界面,根據(jù)安裝需求選擇安裝類型(推薦默認(rèn)開發(fā)版本),設(shè)置MySQL安裝路徑和數(shù)據(jù)存放路徑,最后點(diǎn)擊“Next”。 5、在檢查要求(Check?Requirements)界面,點(diǎn)擊“Next”。 6、安裝進(jìn)度(Installation?progress)界面,點(diǎn)擊“Execute”執(zhí)行。 7、等待安裝進(jìn)度完畢,點(diǎn)擊“Next”。 8、進(jìn)入配置概述(Configuration?Overview)界面,點(diǎn)擊“Next”。 9、在MySQL服務(wù)配置(MySQL?Server?Configuration)界面,默認(rèn)不做修改,點(diǎn)擊“Next”。 10、設(shè)置根賬戶(root賬戶)密碼。 11、添加(非根)用戶賬戶。其目的是便于數(shù)據(jù)庫權(quán)限管理,為遠(yuǎn)程訪問者提供安全賬戶。 12、默認(rèn)windows服務(wù)配置不做修改,點(diǎn)擊“Next”。 13、回到配置概述(Configuration?Overview)界面,安裝完畢點(diǎn)擊“Next”。 14、MySQL安裝完成(Installation?Complete),點(diǎn)擊“Finish”。 15、若勾選“安裝后啟動(dòng)Mysql工作臺”(Start?Mysql?Workbench?after?Setup),可見如下界面。 注意:MySQL環(huán)境變量配置。 ??? 在windows命令提示符中輸入mysql,提示“mysql”不是內(nèi)部或外部命令。只需將MySQL安裝路徑添加系統(tǒng)環(huán)境變量即可。 ?? ?如安裝路徑為“D:\Program?Files\MySQL”目錄,則進(jìn)入mysql?server的bin目錄下復(fù)制路徑;其次在環(huán)境變量中編輯變量Path,變量值中輸入“;”后粘貼“D:\Program?Files\MySQL\MySQL?Server?5.7\bin”路徑,最后從新打開命令提示符窗口運(yùn)行mysql即可

為圍場等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及圍場網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、圍場網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

如何初始化mysql數(shù)據(jù)

一、mysql_install_db說明

當(dāng)MySQL的系統(tǒng)庫(mysql系統(tǒng)庫)發(fā)生故障或需要新加一個(gè)mysql實(shí)例時(shí),需要初始化mysql數(shù)據(jù)庫。

需要使用的命令:/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

除了支持以上的參數(shù),還支持mysqld的參數(shù)。

二、舉例:

本文以新加一個(gè)mysql實(shí)例為例。例如服務(wù)器上已經(jīng)安裝了3306端口的mysql服務(wù),需要再啟一個(gè)3308端口的mysql服務(wù)。

假設(shè)mysql安裝在/usr/local/mysql路徑下,找一個(gè)磁盤空間剩余比較大的盤,如/data1,把3308端口的mysql的數(shù)據(jù)保存在/data1下

#mkdir /data1/mysql_3308

#mkdir /data1/mysql_3308/data

#chown -R mysql:mysql /data1/mysql_3308

復(fù)制一個(gè)mysql配置文件my點(diǎn)吸煙 f到/data1/mysql_3308目錄下

#vi /data1/mysql_3308/my點(diǎn)吸煙 f

修改配置文件,將端口和相關(guān)目錄的都改為新的設(shè)置,如下:

[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

......其他略

確保配置文件無誤。

運(yùn)行下面命令進(jìn)行數(shù)據(jù)庫的初始化:

#/usr/local/mysql/bin/mysql_install_db --defaults-file=/data1/mysql_3308/my點(diǎn)吸煙 f --datadir=/data1/mysql_3308/data

完成后新的3308數(shù)據(jù)庫就初始化好了,如果有報(bào)錯(cuò),則按照報(bào)錯(cuò)的提示查看報(bào)錯(cuò)日志,一般情況下都是my點(diǎn)吸煙 f配置文件的問題,修正后即可。

三、啟動(dòng)新mysql

啟動(dòng)3308端口的mysql服務(wù)

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/data1/mysql_3309/my點(diǎn)吸煙 f

檢查是否啟動(dòng)

#ps aux|grep mysql

如果有3308字樣說明已經(jīng)啟動(dòng)成功

可將啟動(dòng)命令加入/etc/rc.local隨服務(wù)器啟動(dòng)

新加的mysql沒有設(shè)置root密碼,可以通過下面命令設(shè)置root密碼:

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

如何初始化MySQL數(shù)據(jù)庫

1、停止mysql服務(wù)

2、刪除mysql的data目錄下的,除mysql這個(gè)目錄外的其他目錄(為保險(xiǎn)期間,先移走)

3、重啟myql即可

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

呵呵,放松,一切都會好起來的!

sql數(shù)據(jù)庫數(shù)據(jù)如何初始化

初始化mysql數(shù)據(jù)庫,在shell中運(yùn)行以下命令:

cd /usr/local/mysql

mkdir sock

cd /usr/local/mysql/bin

初始化數(shù)據(jù)庫

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

或者# mysqld --initialize

名稱欄目:怎么將mysql初始化 mysql怎么初始化數(shù)據(jù)
標(biāo)題網(wǎng)址:http://muchs.cn/article34/ddcgdpe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化服務(wù)器托管、做網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)定制開發(fā)、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化