mysql学习-安装
发表于:2025-11-08 作者:千家信息网编辑
千家信息网最后更新 2025年11月08日,一、mysql安装包解压,注意下载的mysql包必须与操作系统版本需求一致。[root@node1 soft]# lsmysql-5.7.11-1.el5.i686.rpm-bundle.tar[ro
千家信息网最后更新 2025年11月08日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>
登陆
密码
数据
数据库
账号
一致
安全
操作系统
再次
参数
命令
版本
用户
系统
需求
新密
学习
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
南京智能软件开发机构
GTEx数据库使用教程
领信互联网科技有限公司
沈阳电脑软件开发技术学校
exce去公式保留数据库
做网站需要什么服务器
大型网站数据库
奇迹mu黄金服务器
数据库统计信息没有收集
湖南省软件开发工程师学费
年度网络安全等级保护
湖南软件开发小程序开发
丝路传说哪个服务器最多
暗黑契约8004服务器不见了
上海越寒互联网科技有限公司
计算机网络技术方面的专利
在线 软件开发 如何挣钱
怀旧服如何更改服务器
mssql数据库购买
计算机网络技术笔记软件推荐
端游cf维修服务器要多久
虚拟服务器技术产生的安全问题
恐鬼症几个服务器
woguo网络安全
口碑好的云服务器哪家好
国际服服务器地址怎样填
计算机网络安全就业如何
163邮箱pop3服务器
富民上门软件开发价格走势
网宣部网络安全