清風追夢enjoy的專欄
rpm安裝mysql 需要下載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
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安裝完畢!