mysql在linux下用yum的安裝,和常用配置:
下載和安裝mysql的repo源安裝mysql、mysql-server mysql-devel設(shè)置隨機(jī)啟動(dòng)啟動(dòng)、停止、重啟mysqld服務(wù)修改配置設(shè)置root用戶以及密碼更新host白名單限制 chkconfig --list |grep mysql 數(shù)字代碼服務(wù)器啟動(dòng)級(jí)別,off  代表不隨機(jī)啟動(dòng)mysqld服務(wù),on代表隨機(jī)啟動(dòng)服務(wù) 如果沒有,手動(dòng)添加開機(jī)啟動(dòng): chkconfig --add mysqld設(shè)置mysqld隨機(jī)啟動(dòng) chkconfig mysqld on4、 啟動(dòng)、停止、重啟mysqld服務(wù)啟動(dòng)mysqld服務(wù) 執(zhí)行如下命令進(jìn)行啟動(dòng),兩種方法都可以: /etc/init.d/mysqld start service mysqld start停止mysqld服務(wù) /etc/init.d/mysqld stop 或 service mysqld stop重啟mysqld服務(wù)  /etc/init.d/mysqld restart  或  service mysqld srestart命令行測試連接mysql mysql yum安裝的mysql,本地root密碼默認(rèn)為空5、修改配置修改mysql的一些配置,數(shù)據(jù)目錄和端口等 vim /etc/my.cnf[mysqld]datadir=/home/mysql/datasocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to PRevent assorted security riskssymbolic-links=0port=8990default-character-set=utf8[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid6、新建root用戶以及密碼方法1: 用SET PASSWord命令 mysql -u root mysql> set password for root@localhost = password('新密碼');方法2:用mysqladmin mysqladmin -u root password 新密碼 如果root已經(jīng)設(shè)置過密碼,采用如下方法 mysqladmin -uroot -p舊密碼 password 新密碼方法3: 用UPDATE直接編輯user表 mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;在丟失root密碼的時(shí)候,可以這樣 service mysqld stop mysqld_safe --skip-grant-tables 這一步驟執(zhí)行的時(shí)候不會(huì)出現(xiàn)新的命令行,你需要重新打開一個(gè)窗口執(zhí)行下面的命令 mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root'; mysql> FLUSH PRIVILEGES;7、更新host白名單限制默認(rèn)root用戶只能在本地登錄,要遠(yuǎn)程登錄,作如下設(shè)置 mysql> update mysql.user set Host="%"  where User="root" and Host="localhost"; mysql> flush privileges;新聞熱點(diǎn)
疑難解答
圖片精選