mysql centos下rpm安裝方式
下載並上傳linux
檢查是否安裝過mysql
rpm -qa|grep -i mysql
--------------------------------------------------------------------
安裝RPM
rpm -ivh your-package.rpm
安裝過程中可能出現下面的警告或者提示:
... conflict with ...
rpm --force -i
強制安裝即可
... is needed by ... ... is not installed ...
rpm -i --force --nodeps
可以忽略所有依賴關係和檔案問題,什麼包都能安裝上,但這種強制安裝的軟體包不能保證完全發揮功能。
--------------------------------------------------------------------------------
解除安裝RPM
rpm -e
包名
注意:沒有.rpm字尾名
... is needed by ...
這說明這個軟體被其他軟體需要,不能隨便解除安裝,可以用rpm -e --nodeps強制解除安裝
-----------------------------------------------------------------
rpm安裝mysql 以5.7為例: 需要下載mysql的四個rpm包: mysql-community-client-5.7.18-1.el6.x86_64.rpm mysql-community-common-5.7.18-1.el6.x86_64.rpm mysql-community-libs-5.7.18-1.el6.x86_64.rpm mysql-community-server-5.7.18-1.el6.x86_64.rpm
1、rpm -qa | grep -i mysql
2、將上一步找到的mysql相關的包都刪除
rpm -e --nodeps mysql-libs* //*號指代實際包名, 請實際情況輸入完整包名
rpm -e mysql-server*(如果有)
rpm -e mysql-client*(如果有)
3、檢查並刪除老版本mysql的開發標頭檔案和庫
命令:
rm -fr /usr/lib/mysql
rm -fr /usr/include/mysql
注意:解除安裝後/var/lib/mysql中的資料及/etc/my.cnf不會刪除,如果確定沒用後就手工刪除
rm -f /etc/my.cnf
rm -fr /var/lib/mysql
rm -fr /usr/share/mysql
4、安裝perl
yum install perl -y
5、下載numactl-2.0.9-2.el6.x86_64.rpm並安裝
rpm -ivh numactl-2.0.9-2.el6.x86_64.rpm
6、安裝mysql(有順序要求)
rpm -ivh mysql-community-common-5.7.18-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.19-1.el6.x86_64.rpm
7、#修改配置檔案位置
[
如果需要更改預設的data資料夾, 請提前更改my.cnf中datadir目錄, socket和pid-file建議還是使用預設的目錄/var/lib/mysql 8、修改/etc/my.cnf檔案,設定資料庫的編碼方式: [client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] character_set_server=utf8 9、如果出現錯誤,請檢視/etc/my.cnf檔案中指定的錯誤log日誌的檔案 10、service mysqld start 11、找到隨機密碼: 在/var/log/mysqld.log中有一行: A temporary password is generated for [email protected],後面就是隨機密碼 # mysql -uroot -p"yAe7QGVJ;HlR"使用隨機密碼登入系統 12、修改預設密碼: set global validate_password_policy=0; set global validate_password_length=6; set password for 'root'@'localhost'=password('123456'); 搞定 13、設定密碼以及檢視編碼方式 mysql> set global validate_password_policy=0; Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=6; Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'localhost'=password('123456'); Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show variables like '%character%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
mysql> 14、給root設定遠端登入許可權 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; 15、chkconfig mysqld on 設定開機啟動 至此,mysql-5.7安裝完畢!