经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » MySQL » 查看文章
MySQL 服务和数据库管理
来源:jb51  时间:2021/11/9 15:10:04  对本文有异议

1、启动和关闭服务指令

1.1windows下Mysql5.7官方MSI安装地址

(选择自己心仪的版本安装):

https://downloads.mysql.com/archives/installer/

1.1.1:win7 会遇到的问题:遇到无法定位程序输入点fesetround于动态链接库 解决办法:

下载C++库地址:

https://support.microsoft.com/en-us/help/3138367/update-for-visual-c-2013-and-visual-c-redistributable-package

下载选中的安装完成,继续下一步即可:

1.2、windows下

(mysql57为mysql服务名称):

  • 启动:net start mysql57
  • 关闭:net stop mysql57

1.3、linux下

(mysql 为mysql服务名称):

启动:[root@localhost ~]service mysql start

关闭:[root@localhost ~]service mysql stop

1.4、windows下cmd窗体进入mysql:

cd到mysql安装的bin目录下:

 C:\Windows\system32>cd C:\Program Files\MySQL\MySQL Server 5.7\bin

连接mysql服务器:

  1. C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p
  2. Enter password: ******
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 3
  5. Server version: 5.7.17-log MySQL Community Server (GPL)
  6.  
  7. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  8.  
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12.  
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14.  
  15. mysql>

mysql 代表客户端命令, -u 后面跟连接的数据库用户, -p 表示需要输入密码。

1.4、数据库管理

1.4.1、创建一个orderManage数据库

  1. mysql> create database orderManage;
  2. Query OK, 1 row affected (0.00 sec)
  3.  

1.4.2、展示所有的数据库

  1. mysql> show databases;
  2. +--------------------+
  3. | Database |
  4. +--------------------+
  5. | information_schema |
  6. | cluster |
  7. | mysql |
  8. | test |
  9. | orderManage|
  10. +--------------------+ 5 rows in set (0.00 sec)
  11.  
  12.  

可以发现,在上面的列表中除了刚刚创建的orderManage外,还有另外 4 个数据库,它们都是安装
MySQL 时系统自动创建的,其各自功能如下。

  • 1、 information_schema:主要存储了系统中的一些数据库对象信息。比如用户表信息、列信息、权限信息、字符集信息、分区信息等。
  • 2、 cluster:存储了系统的集群信息。
  • 3 、mysql:存储了系统的用户权限信息。
  • 4、 test:系统自动创建的测试数据库,任何用户都可以使用。

1.4.3、选择进入某一个数据

选择进入orderManage数据库中:

  1. mysql> use ordermanage;
  2. Database changed
  3.  
  4.  

由此可以发现,选择进入数据库时候,数据库的名称是不区分大小写的

1.4.4、查看此数据库中的所有表

  1. mysql> show tables;
  2. Empty set (0.00 sec)
  3.  
  4.  

此时,显示orderManage数据库中是没有表的(Empty set表示操作结果为空)

 1.4.5、删除数据库

  1. mysql> drop database ordermanage;
  2. Query OK, 0 rows affected (0.01 sec)
  3.  
  4.  

1.5、配置MySQL允许远程访问

通过ip连接出现如下问题:

  解决方法:

 以root 用户进入mysql数据库,并查询登录用户信息:

  1. mysql -u root -p
  2.  
  3. use mysql;
  4.  
  5. select host from user where user = 'root'


将host设置为%

  1. update user set host='%' where user='root';
  2.  
  3.  

Host修改完成后记得执行flush privileges使配置立即生效即可

  1. flush privileges;

到此这篇关于MySQL 服务与数据库管理的文章就介绍到这了,更多相关MySQL 服务与数据库管理内容请搜索w3xue以前的文章或继续浏览下面的相关文章希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号