http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/html
http://dev.mysql.com/downloads/repo/yum/mysql
下載到本地再上傳到服務器,或者使用wget 直接下載sql
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
將platform-and-version-specific-package-name
替換爲你下載的rpm名數據庫
sudo rpm -Uvh platform-and-version-specific-package-name.rpm
例如windows
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
yum install -y mysql-community-server
若是網絡環境不是很好,執行完命令就能夠去泡杯茶🍵或者榮耀殺一局(能夠本身先下載好相應的rpm包或直接下載...bundle.tar壓縮包)安全
service mysqld start(重啓是restart,徹底弄好MySQL後最好添加lower_case_table_names=1到[mysqld]下面一行而後重啓MySQL,這是爲了和windows兼容,還有就是在[mysql]下面一行加入default-character-set=utf8)
systemctl start mysqld.service(這個是上面步驟執行後自動輸出的,我這邊的全稱是:Redirecting to /bin/systemctl start mysqld.service) 而後回到[.....]#
service mysqld status
systemctl status mysqld.service(也是系統自動輸出的,我這邊全稱是:Redirecting to /bin/systemctl status mysqld.service) 而後會輸出一大段關於MySQL狀態的信息:
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2017-07-30 08:24:29 CST; 26s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 58507 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 58426 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 58511 (mysqld)
CGroup: /system.slice/mysqld.service
└─58511 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/my...服務器
7月 30 08:24:21 localhost.localdomain systemd[1]: Starting MySQL Server...
7月 30 08:24:29 localhost.localdomain systemd[1]: Started MySQL Server.(注意這句話,說明此時MySQL服務已經在運行)網絡
Mysql5.7默認安裝以後root是有密碼的。dom
爲了增強安全性,MySQL5.7爲root用戶隨機生成了一個密碼,在error log中,關於error log的位置,若是安裝的是RPM包,則默認是/var/log/mysqld.log。
只有啓動過一次mysql才能夠查看臨時密碼ide
grep 'temporary password' /var/log/mysqld.log(若是以前安裝過MySQL則這裏可能會有多個密碼,用最後一個,注意這個密碼輸入時是能夠粘貼的)
這裏的密碼是YdsGaxOq>2n!
使用默認的密碼登錄
mysql -uroot -p(這是一個MySQL的以密碼登陸root用戶的命令)
用該密碼登陸到服務端後,必須立刻修改密碼再執行一些數據庫操做,否則會報以下錯誤:
mysql> select @@log_error; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql>
修改密碼(注意,登陸後的操做後面都最好要有;結尾)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';
若是密碼設置太簡單出現如下的提示
如何解決ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
呢? 這裏直接提供解決方案文末有詳細的說明
必須修改兩個全局參數:
首先,修改validate_password_policy參數的值
mysql> set global validate_password_policy=0;
再修改密碼的長度
set global validate_password_length=1;
再次執行修改密碼就能夠了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';(ALTER等能夠寫成小寫)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION; FLUSH PRIVILEGES;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements