您好,登錄后才能下訂單哦!
這篇文章主要講解了centos7下如何安裝mysql6初始化安裝密碼,內(nèi)容清晰明了,對此有興趣的小伙伴可以學習一下,相信大家閱讀完之后會有幫助。
1.先停止數(shù)據(jù)庫服務(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 = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-grant-tables 此處!?。。。?! # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0
4.重啟數(shù)據(jù)庫
systemctl restart mysql
5.登錄數(shù)據(jù)庫
mysql -uroot -p
如果詢問密碼,直接空密碼登錄
6.set password for root@localhost = password('123456');括號里面的密碼你自己修改。
7.mysql -uroot -p123456 登錄成功
PS:下面看下Mysql初始化root密碼和允許遠程訪問
mysql默認root用戶沒有密碼,輸入mysql –u root 進入mysql
1、初始化root密碼
進入mysql數(shù)據(jù)庫
mysql>update user set password=PASSWORD(‘123456') where User='root';
2、允許mysql遠程訪問,可以使用以下三種方式:
a、改表。
mysql -u root –p mysql>use mysql; mysql>update user set host = '%' where user = 'root'; mysql>select host, user from user;
b、授權(quán)。
例如,你想root使用123456從任何主機連接到mysql服務(wù)器。
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
如果你想允許用戶jack從ip為10.10.50.127的主機連接到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的機器上運行:
//進入MySQL服務(wù)器 d:\mysql\bin\>mysql -h localhost -u root //賦予任何主機訪問數(shù)據(jù)的權(quán)限 mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //使修改生效 mysql>FLUSH PRIVILEGES //退出MySQL服務(wù)器 mysql>EXIT
看完上述內(nèi)容,是不是對centos7下如何安裝mysql6初始化安裝密碼有進一步的了解,如果還想學習更多內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。