centos7下安裝mysql6初始化安裝密碼的方法
1.先停止數(shù)據(jù)庫(kù)服務(wù)器
service mysqld stop
2.vim /etc/my.cnf
3.配置文件添加skip-grant-tables
[root@VM_0_8_centos ~]# vim /etc/my.cnf# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M## Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2Mdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockskip-grant-tables 此處!?。。。。? Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0
4.重啟數(shù)據(jù)庫(kù)
systemctl restart mysql
5.登錄數(shù)據(jù)庫(kù)
mysql -uroot -p
如果詢問(wèn)密碼,直接空密碼登錄
6.set password for root@localhost = password(’123456’);括號(hào)里面的密碼你自己修改。
7.mysql -uroot -p123456 登錄成功
PS:下面看下Mysql初始化root密碼和允許遠(yuǎn)程訪問(wèn)
mysql默認(rèn)root用戶沒(méi)有密碼,輸入mysql ?u root 進(jìn)入mysql
1、初始化root密碼
進(jìn)入mysql數(shù)據(jù)庫(kù)
mysql>update user set password=PASSWORD(‘123456’) where User=’root’;
2、允許mysql遠(yuǎn)程訪問(wèn),可以使用以下三種方式:
a、改表。
mysql -u root ?pmysql>use mysql;mysql>update user set host = ’%’ where user = ’root’;mysql>select host, user from user;
b、授權(quán)。
例如,你想root使用123456從任何主機(jī)連接到mysql服務(wù)器。
mysql>GRANT ALL PRIVILEGES ON *.* TO ’root’@’%’ IDENTIFIED BY ’123456’ WITH GRANT OPTION;
如果你想允許用戶jack從ip為10.10.50.127的主機(jī)連接到mysql服務(wù)器,并使用654321作為密碼
mysql>GRANT ALL PRIVILEGES ON *.* TO ’jack’@’10.10.50.127’ IDENTIFIED BY ’654321’ WITH GRANT OPTION;mysql>FLUSH RIVILEGES
c:在安裝mysql的機(jī)器上運(yùn)行:
//進(jìn)入MySQL服務(wù)器d:mysqlbin>mysql -h localhost -u root//賦予任何主機(jī)訪問(wèn)數(shù)據(jù)的權(quán)限mysql>GRANT ALL PRIVILEGES ON *.* TO ’root’@’%’ WITH GRANT OPTION//使修改生效mysql>FLUSH PRIVILEGES//退出MySQL服務(wù)器mysql>EXIT
總結(jié)
到此這篇關(guān)于centos7下安裝mysql6初始化安裝密碼的方法的文章就介紹到這了,更多相關(guān)centos7下安裝mysql6初始化安裝密碼內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. ACCESS轉(zhuǎn)SQL數(shù)據(jù)庫(kù)相關(guān)的幾個(gè)技能2. MySQL中InnoDB和MyISAM類型的差別3. sql server 災(zāi)難恢復(fù)4. 講解SQL Server數(shù)據(jù)庫(kù)備份的多種方式5. 淺談SELECT?*會(huì)導(dǎo)致查詢效率低的原因6. Mybatis自關(guān)聯(lián)查詢一對(duì)多查詢的實(shí)現(xiàn)示例7. mysql8.0.20數(shù)據(jù)目錄遷移的方法8. SQLite教程(五):索引和數(shù)據(jù)分析/清理9. DB2數(shù)據(jù)庫(kù)部分日常實(shí)用操作10. DB2的高可用性和災(zāi)難恢復(fù)概述
