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)程訪問者提供安全賬戶。
為乳源等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及乳源網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、乳源網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
1、停止mysql服務(wù)
2、刪除mysql的data目錄下的,除mysql這個(gè)目錄外的其他目錄(為保險(xiǎn)期間,先移走)
3、重啟myql即可
-----------------------------------
呵呵,放松,一切都會好起來的!
一、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.cnf到/data1/mysql_3308目錄下
#vi /data1/mysql_3308/my.cnf
修改配置文件,將端口和相關(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.cnf --datadir=/data1/mysql_3308/data
完成后新的3308數(shù)據(jù)庫就初始化好了,如果有報(bào)錯,則按照報(bào)錯的提示查看報(bào)錯日志,一般情況下都是my.cnf配置文件的問題,修正后即可。
三、啟動新mysql
啟動3308端口的mysql服務(wù)
#/usr/local/mysql/bin/mysqld_safe --defaults-file=/data1/mysql_3309/my.cnf
檢查是否啟動
#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_install_db,用于初始化mysql的數(shù)據(jù)庫,生成元數(shù)據(jù)。
若不加任何參數(shù),則該命令按照/etc/my.cnf文件配置執(zhí)行初始化工作,否則可參照如下幫助手動執(zhí)行參數(shù)。
$ 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.
當(dāng)在Ubuntu中執(zhí)行命令sudo apt-get install mysql-server5.1安裝的時(shí)候居然沒有提示我輸入mysql的密碼之類的信息,但是當(dāng)安裝好之后再終端中直接輸入mysql的時(shí)候又能直接進(jìn)入mysql中,雖然可以進(jìn)入mysql中但是我對mysql的密碼一點(diǎn)都不知道,所以這個(gè)時(shí)候安裝的mysql就相當(dāng)于沒有安裝,因?yàn)椴荒苡贸绦蜻M(jìn)行操作mysql數(shù)據(jù)庫(因?yàn)椴僮鲾?shù)據(jù)庫都需要mysql數(shù)據(jù)的密碼的),為了解決ubuntu中mysql密碼初始化的方法有一下兩種:
(1)打開/etc/mysql/debian.cnf文件,在這個(gè)文件中有系統(tǒng)默認(rèn)給我們分配的用戶名和密碼,通過這個(gè)密碼就可以直接對mysql進(jìn)行操作了。但是一般這個(gè)密碼都比較怪,很長很長。
(2)當(dāng)進(jìn)入mysql之后修改mysql的密碼:這個(gè)方法比較好,具體的操作如下用命令:set password for 'root'@'localhost' = password('yourpass');當(dāng)修改之后就可應(yīng)正常對mysql進(jìn)行操作了。
初始化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
本文標(biāo)題:mysql文件怎么初始化 如何初始化mysql數(shù)據(jù)庫
分享地址:http://chinadenli.net/article28/hgdscp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、電子商務(wù)、App設(shè)計(jì)、網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)、商城網(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)