怎么重新初始化mysql 怎么重新初始化打印機(jī)

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

一、mysql_install_db說明

我們提供的服務(wù)有:網(wǎng)站制作、網(wǎng)站設(shè)計、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、東寧ssl等。為超過千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的東寧網(wǎng)站制作公司

當(dāng)MySQL的系統(tǒng)庫(mysql系統(tǒng)庫)發(fā)生故障或需要新加一個mysql實例時,需要初始化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ù)。

二、舉例:

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

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

#mkdir /data1/mysql_3308

#mkdir /data1/mysql_3308/data

#chown -R mysql:mysql /data1/mysql_3308

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

#vi /data1/mysql_3308/my點吸煙 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點吸煙 f --datadir=/data1/mysql_3308/data

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

三、啟動新mysql

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

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/data1/mysql_3309/my點吸煙 f

檢查是否啟動

#ps aux|grep mysql

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

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

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

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

如何初始化mysql數(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

擴(kuò)展資料

mysql數(shù)據(jù)庫的備份

1、物理冷備份,需要在數(shù)據(jù)庫關(guān)閉狀態(tài)下進(jìn)行,能夠較好的保證數(shù)據(jù)庫的完整性。一般用于非核心業(yè)務(wù),這類業(yè)務(wù)一般都允許終端,物理冷備份的特點就是速度快,恢復(fù)操作簡單。通常通過直接打包數(shù)據(jù)庫文件夾(如:/usr/local/mysql/data)來實現(xiàn)

2、通過啟用二進(jìn)制日志進(jìn)行增量備份,MySQL支持增量備份,進(jìn)行增量備份時必須啟用二進(jìn)制日志。二進(jìn)制日志文件為用戶提供復(fù)制,對執(zhí)行備份點后進(jìn)行的數(shù)據(jù)庫更改所需的信息進(jìn)行恢復(fù)。如果進(jìn)行增量備份,需要刷新二進(jìn)制日志。

參考資料來源:百度百科—mySQL

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

1、停止mysql服務(wù)

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

3、重啟myql即可

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

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

新聞名稱:怎么重新初始化mysql 怎么重新初始化打印機(jī)
轉(zhuǎn)載注明:http://muchs.cn/article20/ddcggjo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、軟件開發(fā)服務(wù)器托管、云服務(wù)器、App設(shè)計電子商務(wù)

廣告

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

網(wǎng)站托管運(yùn)營