標籤:server 資料庫 作業系統 修改密碼 localhost
1) 作業系統環境:CentOS6.6
2) 任務:源碼安裝mysql
3) 問題:mysql源碼配置失敗,不知道是包的問題還是系統缺少庫檔案?沒法編譯,通過rpm包也無法安裝,以失敗告終。
4) 解決:為瞭解決問題,通過採用yum安裝成功MYSQL資料庫。
5) 裝過程如下:
[[email protected] tools]#yum –y install mysql-server
[[email protected] tools]#yum -y install php-mysql
[[email protected] tools]# chkconfig mysqld on
[[email protected] tools]# service mysqldstart
[[email protected] tools]# mysqladmin -u rootpassword sky //無法修改密碼
mysqladmin: connect to server at‘localhost‘ failed
error: ‘Access denied for user‘root‘@‘localhost‘ (using password: NO)‘
[[email protected] tools]# service mysqld stop
[[email protected] tools]# mysqld_safe--skip-grant-tables &
[[email protected] tools]#update user setpassword=PASSWORD("sky")where user="root";
[[email protected] tools]# mysql –u root –p
Msql>
Mysql>use mysql
mysql> update user set password=PASSWORD("sky")whereuser="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> flush privileges; //更新許可權
Query OK, 0 rows affected (0.00 sec)
//到此為止,你設定了新密碼,通過新密碼正常可以登入到mysql資料。
注意事項:既然是通過yum安裝,通常我們要配置和最佳化資料庫,哪麼就要清楚設定檔存放在哪,所以說我們掌握原始碼安裝方式非常重要,下列是通過yum源安裝常用的預設目錄:
資料庫目錄:/var/lib/mysql/
設定檔:/usr/share/mysql
相關命令:/usr/bin [例如mysql、mysqladmin、mysqldump、mysqlshow等]
啟動指令碼:/etc/rc.d/init.d/
本文出自 “營運” 部落格,請務必保留此出處http://sky9896.blog.51cto.com/2330653/1591391
yum安裝mysql資料庫