1、啟動和關(guān)閉服務指令
1.1windows下mysql5.7官方msi安裝地址
(選擇自己心儀的版本安裝):
https://downloads.mysql.com/archives/installer/
1.1.1:win7 會遇到的問題:遇到無法定位程序輸入點fesetround于動態(tài)鏈接庫 解決辦法:
下載c++庫地址:
https://support.microsoft.com/en-us/help/3138367/update-for-visual-c-2013-and-visual-c-redistributable-package
下載選中的安裝完成,繼續(xù)下一步即可:
1.2、windows下
(mysql57為mysql服務名稱):
-
啟動:
net start mysql57
-
關(guān)閉:
net stop mysql57
1.3、linux下
(mysql 為mysql服務名稱):
啟動:[root@localhost ~]service mysql start
關(guān)閉:[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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
c:\program files\mysql\mysql server 5.7\bin>mysql -uroot -p enter password : ****** welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 3 server version: 5.7.17-log 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
代表客戶端命令, -u
后面跟連接的數(shù)據(jù)庫用戶, -p
表示需要輸入密碼。
1.4、數(shù)據(jù)庫管理
1.4.1、創(chuàng)建一個ordermanage數(shù)據(jù)庫
1
2
|
mysql> create database ordermanage; query ok, 1 row affected (0.00 sec) |
1.4.2、展示所有的數(shù)據(jù)庫
1
2
3
4
5
6
7
8
9
10
|
mysql> show databases; + --------------------+ | database | + --------------------+ | information_schema | | cluster | | mysql | | test | | ordermanage| + --------------------+ 5 rows in set (0.00 sec) |
可以發(fā)現(xiàn),在上面的列表中除了剛剛創(chuàng)建的ordermanage
外,還有另外 4 個數(shù)據(jù)庫,它們都是安裝
mysql
時系統(tǒng)自動創(chuàng)建的,其各自功能如下。
-
1、
information_schema
:主要存儲了系統(tǒng)中的一些數(shù)據(jù)庫對象信息。比如用戶表信息、列信息、權(quán)限信息、字符集信息、分區(qū)信息等。 -
2、
cluster
:存儲了系統(tǒng)的集群信息。 -
3 、
mysql
:存儲了系統(tǒng)的用戶權(quán)限信息。 -
4、
test
:系統(tǒng)自動創(chuàng)建的測試數(shù)據(jù)庫,任何用戶都可以使用。
1.4.3、選擇進入某一個數(shù)據(jù)
選擇進入ordermanage數(shù)據(jù)庫中:
1
2
|
mysql> use ordermanage; database changed |
由此可以發(fā)現(xiàn),選擇進入數(shù)據(jù)庫時候,數(shù)據(jù)庫的名稱是不區(qū)分大小寫的
1.4.4、查看此數(shù)據(jù)庫中的所有表
1
2
|
mysql> show tables; empty set (0.00 sec) |
此時,顯示ordermanage
數(shù)據(jù)庫中是沒有表的(empty set表示操作結(jié)果為空)
1.4.5、刪除數(shù)據(jù)庫
1
2
|
mysql> drop database ordermanage; query ok, 0 rows affected (0.01 sec) |
1.5、配置mysql允許遠程訪問
通過ip連接出現(xiàn)如下問題:
解決方法:
以root 用戶進入mysql數(shù)據(jù)庫,并查詢登錄用戶信息:
1
2
3
4
5
|
mysql -u root -p use mysql; select host from user where user = 'root' |
將host設置為%
1
|
update user set host= '%' where user = 'root' ; |
host修改完成后記得執(zhí)行flush privileges使配置立即生效即可
1
2
|
flush privileges ; |
到此這篇關(guān)于mysql 服務與數(shù)據(jù)庫管理的文章就介紹到這了,更多相關(guān)mysql 服務與數(shù)據(jù)庫管理內(nèi)容請搜索服務器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務器之家!
原文鏈接:https://www.cnblogs.com/19930521zhang/p/14754193.html