mysql學習-安裝
一、mysql安裝包解壓,注意下載的mysql包必須與作業系統版本需求一致。
[root@node1 soft]# ls
mysql-5.7.11-1.el5.i686.rpm-bundle.tar
[root@node1 soft]# ls -l
total 600552
-rw-r--r-- 1 root root 614359040 Feb 18 12:02 mysql-5.7.11-1.el5.i686.rpm-bundle.tar
[root@node1 soft]# tar -xvf mysql-5.7.11-1.el5.i686.rpm-bundle.tar
mysql-community-libs-5.7.11-1.el5.i686.rpm
mysql-community-common-5.7.11-1.el5.i686.rpm
mysql-community-libs-compat-5.7.11-1.el5.i686.rpm
mysql-community-server-5.7.11-1.el5.i686.rpm
mysql-5.7.11-1.el5.i686.rpm
mysql-community-test-5.7.11-1.el5.i686.rpm
mysql-community-devel-5.7.11-1.el5.i686.rpm
mysql-community-client-5.7.11-1.el5.i686.rpm
mysql-community-embedded-5.7.11-1.el5.i686.rpm
mysql-community-embedded-devel-5.7.11-1.el5.i686.rpm
二、安裝mysql
[root@node1 soft]# rpm -ivh mysql-community-server-5.7.11-1.el5.i686.rpm
warning: mysql-community-server-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
error: Failed dependencies:
mysql-community-client = 5.7.11-1.el5 is needed by mysql-community-server-5.7.11-1.el5.i686
mysql-community-common = 5.7.11-1.el5 is needed by mysql-community-server-5.7.11-
1.el5.i686
[root@node1 soft]# rpm -ivh mysql-community-server-5.7.11-1.el5.i686.rpm --force --nodeps
warning: mysql-community-server-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-server ########################################### [100%]
[root@node1 soft]#
[root@node1 soft]#
--mysql會自動新增mysql使用者
[root@node1 soft]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
[root@node1 soft]# ls -l
total 1201144
-rw-r--r-- 1 7155 wheel 40516 Feb 2 17:27 mysql-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 root root 614359040 Feb 18 12:02 mysql-5.7.11-1.el5.i686.rpm-bundle.tar
-rw-r--r-- 1 7155 wheel 32644512 Feb 2 17:31 mysql-community-client-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 825859 Feb 2 17:31 mysql-community-common-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 5402990 Feb 2 17:31 mysql-community-devel-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 53512687 Feb 2 17:31 mysql-community-embedded-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 168617172 Feb 2 17:31 mysql-community-embedded-devel-5.7.11-
1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 2968131 Feb 2 17:32 mysql-community-libs-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 2172050 Feb 2 17:32 mysql-community-libs-compat-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 209431525 Feb 2 17:33 mysql-community-server-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 138730825 Feb 2 17:34 mysql-community-test-5.7.11-1.el5.i686.rpm
三、安裝msql client
[root@node1 soft]# rpm -ivh mysql-community-client-5.7.11-1.el5.i686.rpm
warning: mysql-community-client-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
error: Failed dependencies:
mysql-community-libs = 5.7.11-1.el5 is needed by mysql-community-client-5.7.11-1.el5.i686
[root@node1 soft]# rpm -ivh mysql-community-client-5.7.11-1.el5.i686.rpm --force --nodeps
warning: mysql-community-client-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@node1 soft]#
四、停止mysql
[root@node1 soft]# mysql
ERROR 1045 (28000): Unknown error 1045
[root@node1 soft]# /etc/rc.d/init.d/mysqld stop
Stopping mysqld: [ OK ]
[root@node1 soft]# netstat -anp|grep 3306
五、使用mysql安全登陸,修改root賬號密碼
[root@node1 ~]# mysqld_safe --skip--tables &
[1] 5379
[root@node1 ~]# Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
grep: write error: Broken pipe
2016-02-29T19:40:08.792329Z mysqld_safe Logging to '/var/log/mysqld.log'.
2016-02-29T19:40:08.861817Z mysqld_safe A mysqld process already exists
[1]+ Exit 1 mysqld_safe --skip--tables
[root@node1 ~]#
/var/lib/mysql
[root@node1 ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> select rurrent_user;
ERROR 1054 (42S22): Unknown error 1054
mysql>
mysql> use mysql
Database changed
mysql>
mysql>
mysql> update mysql.user set authentication_string=password('root') where user='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@node1 ~]# /etc/init.d/mysql restart
-bash: /etc/init.d/mysql: No such file or directory
[root@node1 ~]# /etc/rc.d/init.d/mysqld start
Starting mysqld: [ OK ]
[root@node1 ~]#
--登陸使用命令報錯,需要關閉validate_password = OFF
[root@node1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.11
Copyright (c) 2000, 2016, 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> create database test;
ERROR 1820 (HY000): Unknown error 1820
mysql>
[root@node1 etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.11
Copyright (c) 2000, 2016, 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>
mysql>
mysql> use mysql
ERROR 1820 (HY000): Unknown error 1820
mysql> update mysql.user set authentication_string=password('root') where user='root';
ERROR 1820 (HY000): Unknown error 1820
mysql>
mysql>
mysql>
mysql> use testdb
ERROR 1820 (HY000): Unknown error 1820
mysql> conn testdb
-> ^C
--修改引數
[root@node1 etc]# vi /etc/my.cnf
validate_password = OFF
---從其mysql
[root@node1 ~]# /etc/rc.d/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@node1 ~]#
mysql> use mysql
ERROR 1820 (HY000): Unknown error 1820
mysql>
mysql>
mysql>
mysql> use testdb
ERROR 1820 (HY000): Unknown error 1820
mysql> select host,user,password from user ;
ERROR 1046 (3D000):
mysql>
mysql>
六、注意需要從新設定賬號密碼,可以使用簡單的密碼
SET PASSWORD = '*0D3CED9BEC10A777AEC23CCC353A8C08A633045E';
mysql> 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
mysql> use testdb;
Database changed
mysql>
---使用新密碼登陸資料庫
[root@node1 etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> 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
mysql>
mysql> uninstall plugin validate_password;
Query OK, 0 rows affected (0.01 sec)
mysql> SET PASSWORD = '1234';
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
---再次登陸資料庫,正常使用
[root@node1 etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>
mysql>
mysql> 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
mysql>
mysql>
[root@node1 soft]# ls
mysql-5.7.11-1.el5.i686.rpm-bundle.tar
[root@node1 soft]# ls -l
total 600552
-rw-r--r-- 1 root root 614359040 Feb 18 12:02 mysql-5.7.11-1.el5.i686.rpm-bundle.tar
[root@node1 soft]# tar -xvf mysql-5.7.11-1.el5.i686.rpm-bundle.tar
mysql-community-libs-5.7.11-1.el5.i686.rpm
mysql-community-common-5.7.11-1.el5.i686.rpm
mysql-community-libs-compat-5.7.11-1.el5.i686.rpm
mysql-community-server-5.7.11-1.el5.i686.rpm
mysql-5.7.11-1.el5.i686.rpm
mysql-community-test-5.7.11-1.el5.i686.rpm
mysql-community-devel-5.7.11-1.el5.i686.rpm
mysql-community-client-5.7.11-1.el5.i686.rpm
mysql-community-embedded-5.7.11-1.el5.i686.rpm
mysql-community-embedded-devel-5.7.11-1.el5.i686.rpm
二、安裝mysql
[root@node1 soft]# rpm -ivh mysql-community-server-5.7.11-1.el5.i686.rpm
warning: mysql-community-server-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
error: Failed dependencies:
mysql-community-client = 5.7.11-1.el5 is needed by mysql-community-server-5.7.11-1.el5.i686
mysql-community-common = 5.7.11-1.el5 is needed by mysql-community-server-5.7.11-
1.el5.i686
[root@node1 soft]# rpm -ivh mysql-community-server-5.7.11-1.el5.i686.rpm --force --nodeps
warning: mysql-community-server-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-server ########################################### [100%]
[root@node1 soft]#
[root@node1 soft]#
--mysql會自動新增mysql使用者
[root@node1 soft]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
[root@node1 soft]# ls -l
total 1201144
-rw-r--r-- 1 7155 wheel 40516 Feb 2 17:27 mysql-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 root root 614359040 Feb 18 12:02 mysql-5.7.11-1.el5.i686.rpm-bundle.tar
-rw-r--r-- 1 7155 wheel 32644512 Feb 2 17:31 mysql-community-client-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 825859 Feb 2 17:31 mysql-community-common-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 5402990 Feb 2 17:31 mysql-community-devel-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 53512687 Feb 2 17:31 mysql-community-embedded-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 168617172 Feb 2 17:31 mysql-community-embedded-devel-5.7.11-
1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 2968131 Feb 2 17:32 mysql-community-libs-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 2172050 Feb 2 17:32 mysql-community-libs-compat-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 209431525 Feb 2 17:33 mysql-community-server-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 138730825 Feb 2 17:34 mysql-community-test-5.7.11-1.el5.i686.rpm
三、安裝msql client
[root@node1 soft]# rpm -ivh mysql-community-client-5.7.11-1.el5.i686.rpm
warning: mysql-community-client-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
error: Failed dependencies:
mysql-community-libs = 5.7.11-1.el5 is needed by mysql-community-client-5.7.11-1.el5.i686
[root@node1 soft]# rpm -ivh mysql-community-client-5.7.11-1.el5.i686.rpm --force --nodeps
warning: mysql-community-client-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@node1 soft]#
四、停止mysql
[root@node1 soft]# mysql
ERROR 1045 (28000): Unknown error 1045
[root@node1 soft]# /etc/rc.d/init.d/mysqld stop
Stopping mysqld: [ OK ]
[root@node1 soft]# netstat -anp|grep 3306
五、使用mysql安全登陸,修改root賬號密碼
[root@node1 ~]# mysqld_safe --skip--tables &
[1] 5379
[root@node1 ~]# Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
grep: write error: Broken pipe
2016-02-29T19:40:08.792329Z mysqld_safe Logging to '/var/log/mysqld.log'.
2016-02-29T19:40:08.861817Z mysqld_safe A mysqld process already exists
[1]+ Exit 1 mysqld_safe --skip--tables
[root@node1 ~]#
/var/lib/mysql
[root@node1 ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> select rurrent_user;
ERROR 1054 (42S22): Unknown error 1054
mysql>
mysql> use mysql
Database changed
mysql>
mysql>
mysql> update mysql.user set authentication_string=password('root') where user='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@node1 ~]# /etc/init.d/mysql restart
-bash: /etc/init.d/mysql: No such file or directory
[root@node1 ~]# /etc/rc.d/init.d/mysqld start
Starting mysqld: [ OK ]
[root@node1 ~]#
--登陸使用命令報錯,需要關閉validate_password = OFF
[root@node1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.11
Copyright (c) 2000, 2016, 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> create database test;
ERROR 1820 (HY000): Unknown error 1820
mysql>
[root@node1 etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.11
Copyright (c) 2000, 2016, 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>
mysql>
mysql> use mysql
ERROR 1820 (HY000): Unknown error 1820
mysql> update mysql.user set authentication_string=password('root') where user='root';
ERROR 1820 (HY000): Unknown error 1820
mysql>
mysql>
mysql>
mysql> use testdb
ERROR 1820 (HY000): Unknown error 1820
mysql> conn testdb
-> ^C
--修改引數
[root@node1 etc]# vi /etc/my.cnf
validate_password = OFF
---從其mysql
[root@node1 ~]# /etc/rc.d/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@node1 ~]#
mysql> use mysql
ERROR 1820 (HY000): Unknown error 1820
mysql>
mysql>
mysql>
mysql> use testdb
ERROR 1820 (HY000): Unknown error 1820
mysql> select host,user,password from user ;
ERROR 1046 (3D000):
mysql>
mysql>
六、注意需要從新設定賬號密碼,可以使用簡單的密碼
SET PASSWORD = '*0D3CED9BEC10A777AEC23CCC353A8C08A633045E';
mysql> 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
mysql> use testdb;
Database changed
mysql>
---使用新密碼登陸資料庫
[root@node1 etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> 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
mysql>
mysql> uninstall plugin validate_password;
Query OK, 0 rows affected (0.01 sec)
mysql> SET PASSWORD = '1234';
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
---再次登陸資料庫,正常使用
[root@node1 etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>
mysql>
mysql> 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
mysql>
mysql>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29108064/viewspace-1990714/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mysql 學習篇之原始碼安裝mysqlMySql原始碼
- Mysql學習筆記(安裝篇)MySql筆記
- Mysql學習筆記1--安裝MySql筆記
- MySQL入門學習之——原始碼安裝mysql5.5MySql原始碼
- mysql學習3:第二章:mysql安裝啟動和關閉——mysql5.6安裝MySql
- mysql學習4:第二章:mysql安裝啟動和關閉——mysql5.7安裝MySql
- mysql dba系統學習(1)mysql各版本編譯安裝MySql編譯
- mysql學習2:第二章:mysql安裝啟動和關閉——安裝前檢查MySql
- 學習安裝 RocketMQMQ
- Redis學習——安裝Redis
- Webpack學習 – Webpack安裝及安裝Web
- 【MySQL學習】在RHEL7.3上使用yum安裝MySQL5.7MySql
- linux環境安裝——mysql安裝複習LinuxMySql
- clickhouse學習(1)-clickhouse安裝解除安裝
- mysql學習之-三種安裝方式與版本介紹MySql
- 學習如何安裝Sass
- go學習--->安裝goGo
- Docker學習(1)安裝Docker
- docker 安裝與學習Docker
- MySQL從0到1學習002--Linux安裝MySQL8.0MySqlLinux
- MySQL學習(二)圖形介面管理工具Navicat for MySQL安裝和使用MySql
- hadoop上安裝hive2.3.2學習總結—hive安裝+mysql以及碰到坑點HadoopHiveMySql
- MySQL學習(一)資料庫安裝與配置全程圖解MySql資料庫圖解
- Git 學習之安裝配置Git
- 深度學習庫安裝list深度學習
- RabbitMQ學習筆記-安裝MQ筆記
- YOLO的安裝與學習YOLO
- Presto學習-presto的安裝REST
- goldengate學習-安裝篇Go
- 學習六:安裝配置HBASE
- Centos學習筆記--安裝CentOS筆記
- linux學習記錄關於tomcat,jdk,oracle,mysql安裝LinuxTomcatJDKOracleMySql
- mysql安裝 (yum 安裝)MySql
- 使用Docker安裝Redis - 學習三DockerRedis
- Hive學習之Hive的安裝Hive
- jenkins安裝與配置學習Jenkins
- Python學習---Pycharm安裝.26PythonPyCharm
- Docker安裝(學習筆記一)Docker筆記