当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL安装与连接

MySQL安装与连接

2019年08月18日  | 移动技术网IT编程  | 我要评论

1.安装

下载地址:

常见问题及解决办法:

1.1.添加环境变量

将解压后的mysql-5.7.21-winx64\bin路径 添加到系统环境变量。

打开我的电脑——空白处右击——属性——高级系统设置——高级——环境变量——双击path,新建,将上述路径复制。

1.2.初始化

以管理员身份运行cmd:mysqld --initialize-insecure

win10环境下均以管理员身份打开cmd,mysql版本5.7.27

2.mysql的启动、连接与关闭
2.1从windows命令行启动mysql
ps c:\windows\system32> mysqld
#此时可以开启客户端进行连接
2.2停止mysql服务器
ps c:\windows\system32> mysqladmin -u root shutdown
#如果mysql root用户账户有密码,你需要调用命令mysqladmin -u root -p shutdown并根据提示输入密码。
2.3以windows服务方式启动mysql

2.3.1安装服务器

ps c:\windows\system32> mysqld --install
service successfully installed.

2.3.2开启mysql服务

ps c:\windows\system32> net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。
#此时可以开启客户端进行连接
#此方法关掉cmd,mysqld进程还在。

2.3.3关闭mysql服务

ps c:\windows\system32>  net stop mysql
mysql 服务正在停止.
mysql 服务已成功停止。

2.3.4卸载服务器

ps c:\windows\system32> mysqld --remove
service successfully removed.
2.4开启客户端、连接服务端
............先开启服务端...........
ps c:\windows\system32> mysql -uroot -p
enter password:
welcome to the mysql monitor.  commands end with ; or \g.
your mysql connection id is 2
server version: 5.7.27 mysql community server (gpl)

copyright (c) 2000, 2019, 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>
#此时可以进行数据库操作,输入exit,回车可退出

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网