安裝mysql資料庫及問題解決方法
1、mysql官網下載安裝包,官網地址:
[root@seiang software]# ll
total 580020
-rw-r--r--. 1 root root 593940480 Mar 25 18:57 mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
2、解壓
[root@seiang software]# tar xvf mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.21-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.21-1.el7.x86_64.rpm
mysql-community-common-5.7.21-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.21-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.21-1.el7.x86_64.rpm
mysql-community-client-5.7.21-1.el7.x86_64.rpm
mysql-community-server-5.7.21-1.el7.x86_64.rpm
mysql-community-embedded-5.7.21-1.el7.x86_64.rpm
mysql-community-test-5.7.21-1.el7.x86_64.rpm
mysql-community-devel-5.7.21-1.el7.x86_64.rpm
mysql-community-libs-5.7.21-1.el7.x86_64.rpm
3、全部安裝,出現如下的報錯
[root@seiang software]# rpm -ivh *.rpm
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mariadb-libs is obsoleted by mysql-community-libs-5.7.21-1.el7.x86_64
mariadb-libs is obsoleted by mysql-community-libs-compat-5.7.21-1.el7.x86_64
perl(Data::Dumper) is needed by mysql-community-test-5.7.21-1.el7.x86_64
perl(JSON) is needed by mysql-community-test-5.7.21-1.el7.x86_64
4、如上的報錯,由於centos 7預設是mariadb資料庫,再去安裝mysql之前要先下載mariadb
[root@seiang software]# rpm -qa | grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@seiang software]# rpm -e mariadb-libs-5.5.41-2.el7_0.x86_64
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
由於存在依賴關係,強制解除安裝
[root@seiang software]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
5、安裝mysql-server,出現報錯
[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.21-1.el7.x86_64
mysql-community-common(x86-64) = 5.7.21-1.el7 is needed by mysql-community-server-5.7.21-1.el7.x86_64
6、根據提示,要先安裝mysql-community-common和mysql-community-client包
[root@seiang software]# rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.21-1.e################################# [100%]
7、安裝mysql-client包,出現如下的報錯
[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.21-1.el7.x86_64
8、根據提示先安裝 mysql-community-libs包
[root@seiang software]# rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.21-1.el7################################# [100%]
9、再次嘗試安裝mysql-client
[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.21-1.e################################# [100%]
10、最後安裝mysql-server
[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.21-1.e################################# [100%]
11、檢視mysql的服務
[root@seiang software]# systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
12、啟動mysql服務
[root@seiang software]# systemctl start mysqld.service
[root@seiang software]#
[root@seiang software]# systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Mon 2018-03-26 09:26:04 CST; 2s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2113 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 2034 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 2116 (mysqld)
CGroup: /system.slice/mysqld.service
鈹斺攢2116 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Mar 26 09:25:54 seiang systemd[1]: Starting MySQL Server...
Mar 26 09:26:04 seiang systemd[1]: Started MySQL Server.
13、mysql服務啟動成功,首先使用臨時的密碼進行登入,檢視臨時密碼
[root@seiang software]# grep "password" /var/log/mysqld.log
2018-03-25T11:18:09.770923Z 1 [Note] A temporary password is generated for root@localhost: &)2KIh?M3hr7
2018-03-25T11:19:39.853663Z 2 [Note] Access denied for user 'root'@'localhost' (using password: YES)
2018-03-25T11:22:20.996230Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2018-03-25T11:24:31.219087Z 0 [Note] Shutting down plugin 'validate_password'
2018-03-25T11:24:33.062278Z 0 [Note] Shutting down plugin 'sha256_password'
2018-03-25T11:24:33.062286Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-03-26T01:25:57.938742Z 1 [Note] A temporary password is generated for root@localhost: v,esvf2?oj?T
14、使用臨時密碼登入,然後修改root的密碼
[root@seiang software]# mysql -uroot -pv,esvf2?oj?T
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'beijing';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qcloud@2018';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
兩次修改都提示相同的錯誤:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
下面是官方文件,對於該問題的解釋:
https://dev.mysql.com/doc/refman/5.7/en/validate-password.html
上述報錯的原因:其實與validate_password_policy的值有關。
validate_password_policy有以下取值:
預設是1,即MEDIUM,所以剛開始設定的密碼必須符合長度,且必須含有數字,小寫或大寫字母,特殊字元。
解決方法:
修改validate_password_policy引數的值
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 8 |
+----------------------------+
1 row in set (0.05 sec)
預設的密碼長度是8,少於8位依舊會出現報錯
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'beijing';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
修改成功
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qcloud@2018';
Query OK, 0 rows affected (0.00 sec)
15、使用新密碼再次登入,登入成功
[root@seiang software]# mysql -uroot -pqcloud@2018
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
16、由於習慣於Linux的提示,所以我們為mysql也設定提示
(1)臨時設定
mysql> prompt \u@ \h \d >
root@ localhost (none) >
root@ localhost (none) >use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
root@ localhost mysql >prompt \u@\h [\d]>
PROMPT set to '\u@\h [\d]>'
root@localhost [mysql]>
root@localhost [mysql]>
(2)永久設定
[root@seiang ~]# vim /etc/my.cnf
新增下面兩句,注意:[]中是mysql,不是mysqld
[mysql]
prompt=\u@\h [\d]>
作者:SEian.G(苦練七十二變,笑對八十一難)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31015730/viewspace-2152272/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 安裝資料庫和資料庫解決問題資料庫
- redis安裝及問題解決Redis
- redis 安裝及安裝遇到的問題解決Redis
- Windows 安裝 MySQL 5.7.20 教程(及常見問題解決)WindowsMySql
- 安裝DBD:MySql模組遇到的問題及解決辦法MySql
- MAC 安裝 VMAF 遇到的問題及解決方法記錄Mac
- IPython的安裝及問題解決Python
- django安裝xadmin及問題解決Django
- Mysql安裝過程中遇到的問題及解決辦法MySql
- Laravel 安裝 voyager 出現的資料庫報錯問題解決Laravel資料庫
- springMVC儲存資料到mysql資料庫中文亂碼問題解決方法SpringMVCMySql資料庫
- 安裝sql server遇到問題解決方法SQLServer
- MySQL資料庫下載及安裝教程MySql資料庫
- linux下安裝mysql的問題解決LinuxMySql
- Oracle資料庫基本知識及問題解決(轉)Oracle資料庫
- 【mysql】配置MySQL,解決安裝過程中的問題MySql
- mysql資料庫安裝及預設儲存路徑修改方法MySql資料庫
- jive安裝連資料庫問題?資料庫
- 【資料庫】解決Mysql資料庫提示innodb表不存在的問題!資料庫MySql
- Win10系統伺服器安裝MySQL8.0.13遇到的問題及解決方法Win10伺服器MySql
- 安裝 laraBBS 原始碼包可能會碰到的問題及解決方法原始碼
- elk(單機)安裝過程中遇到的問題及解決方法
- Oracle RAC之--安裝過程中碰到的問題及解決方法Oracle
- Mysql安裝過程問題總結及處理方法MySql
- 【PG資料庫】PG資料庫的安裝及連線方法資料庫
- linux下安裝loudmouth庫中碰到的問題 & 解決方法薦Linux
- windows安裝tomcat遇到問題及解決方案WindowsTomcat
- 轉:Git伺服器安裝詳解及安裝遇到問題解決方案Git伺服器
- MYSQL亂碼問題解決方法MySql
- OA系統資料面臨的安全問題及解決方法
- Pyaudio庫的安裝及問題
- MySQL主從資料庫同步延遲問題怎麼解決MySql資料庫
- 解決Hibernate向MySQL資料庫插入中文亂碼問題MySql資料庫
- 資料庫突然當機無法open的問題及解決資料庫
- Ubuntu安裝MySQL資料庫UbuntuMySql資料庫
- 原始碼安裝apache(附遇到的問題及解決)原始碼Apache
- VMware下安裝Ubuntu遇到的問題及解決方案Ubuntu
- WINDOWS下安裝MYSQL資料庫教程詳解WindowsMySql資料庫