準備好mysql的離線安裝文件: MySql官網下載mysql-5.7.25-1.el7.x86_64.rpm-bundle,並複製到/usr/mysql文件夾中。 刪除CentOS自帶的MariaDB: rpm -qa|grep mariadb rpm -e --nodeps mariadb-li ...
準備好mysql的離線安裝文件:
MySql官網下載mysql-5.7.25-1.el7.x86_64.rpm-bundle,並複製到/usr/mysql文件夾中。
刪除CentOS自帶的MariaDB:
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs
rpm命令安裝:
cd /usr/mysql/ mysql-5.7.25-1.el7.x86_64.rpm-bundle
rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
啟動MySql服務:
查看MySql運行狀態:service mysqld status
啟動MySql:systemctl start mysqld
查看root隨機密碼:
MySQL5.7會在安裝後為root用戶生成一個隨機密碼,而不是像以往版本的空密碼。可以安全模式修改root登錄密碼或者用隨機密碼登錄修改密碼。下麵用隨機密碼方式,MySQL為root用戶生成的隨機密碼通過mysqld.log文件可以查找到:
grep 'temporary password' /var/log/mysqld.log
修改root登錄密碼:
MySQL的密碼策略比較複雜,過於簡單的密碼會被拒絕
mysql -u root -p
mysql> Enter password: (輸入剛纔查詢到的隨機密碼)
mysql> SET PASSWORD FOR 'root'@'localhost'= "123456";
mysql> exit
設置root可以遠程登錄:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql>exit;
開啟防火牆mysql 3306埠的外部訪問:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
設置MySql忽略大小寫:
用root登錄,打開並修改 /etc/my.cnf;在[mysqld]節點下,加入一行: lower_case_table_names=1。
重啟MySql服務:systemctl restart mysqld