問(wèn)mySQL是怎么配置的 mysql配置的兩種方式

怎么配置mysql數(shù)據(jù)庫(kù)配置文件

一、mysql_install_db說(shuō)明

創(chuàng)新互聯(lián)公司是一家專(zhuān)業(yè)的成都網(wǎng)站建設(shè)公司,我們專(zhuān)注網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)絡(luò)營(yíng)銷(xiāo)、企業(yè)網(wǎng)站建設(shè),賣(mài)鏈接,廣告投放為企業(yè)客戶(hù)提供一站式建站解決方案,能帶給客戶(hù)新的互聯(lián)網(wǎng)理念。從網(wǎng)站結(jié)構(gòu)的規(guī)劃UI設(shè)計(jì)到用戶(hù)體驗(yàn)提高,創(chuàng)新互聯(lián)力求做到盡善盡美。

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

需要使用的命令:/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è)磁盤(pán)空間剩余比較大的盤(pán),如/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

......其他略

確保配置文件無(wú)誤。

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

#/usr/local/mysql/bin/mysql_install_db --defaults-file=/data1/mysql_3308/my.cnf --datadir=/data1/mysql_3308/data

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

三、啟動(dòng)新mysql

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

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/data1/mysql_3309/my.cnf

檢查是否啟動(dòng)

#ps aux|grep mysql

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

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

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

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

mysql5.7配置文件怎么配置

Mysql的配置文件:

!includedir /etc/mysql/conf.d/

!includedir /etc/mysql/mysql.conf.d/

這兩行的意思是配置文件在這兩個(gè)目錄下,也就是說(shuō)你可以在這兩個(gè)目錄下配置,最好是不要直接改變

my.cnf文件, 因?yàn)樗鼤?huì)導(dǎo)致一些問(wèn)題, 比如當(dāng)在升級(jí) Ubuntu/Mysql 到一個(gè)新的版本時(shí).這里我們創(chuàng)建一個(gè)新文件:sudo vim

/etc/mysql/conf.d/utf8.cnf

utf8.cnf配置文件內(nèi)容為:

[mysqld]

character-set-server=utf8

collation-server=utf8_general_ci

[client]

default-character-set=utf8

怎么配置MySQL數(shù)據(jù)庫(kù)讓別人遠(yuǎn)程訪問(wèn)

有三種方法:

方法一(不推薦)、本地登入mysql,更改?"mysql"?數(shù)據(jù)庫(kù)里的?"user"?表里的?"host"?項(xiàng),將"localhost"改為"%"

#mysql?-u?root?-proot

mysqluse?mysql;

mysqlupdate?user?set?host?=?'%'?where?user?=?'root';

mysqlselect?host,?user?from?user;

方法二、直接授權(quán)(推薦)

從任何主機(jī)上使用root用戶(hù),密碼:youpassword(你的root密碼)連接到mysql服務(wù)器:(首先登陸Linux服務(wù)器,填寫(xiě)下面代碼即可)

[root@localhost?software]#?mysql?-u?root?-proot?

mysqlGRANT?ALL?PRIVILEGES?ON?*.*?TO?'root'@'%'?IDENTIFIED?BY?'youpassword'?WITH?GRANT?OPTION;

mysqlFLUSH?PRIVILEGES;

操作完后切記執(zhí)行以下命令刷新權(quán)限

FLUSH?PRIVILEGES;

方法三:終極方法

注釋bind-address?=?127.0.0.1

找到mysql.cnf

把bind-address?=?127.0.0.1?前面加上?#

即??#bind-address?=?127.0.0.1

網(wǎng)站名稱(chēng):問(wèn)mySQL是怎么配置的 mysql配置的兩種方式
網(wǎng)頁(yè)地址:http://muchs.cn/article36/doeocsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、網(wǎng)站導(dǎo)航網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)動(dòng)態(tài)網(wǎng)站App開(kāi)發(fā)

廣告

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

成都定制網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)