欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

linux下MySQL初始環(huán)境設(shè)定

[1]為MySQL的root用戶設(shè)置密碼

MySQL在剛剛被安裝的時候,它的root用戶是沒有被設(shè)置密碼的。首先來設(shè)置MySQL的root密碼。[@more@]


[root@sample ~]# mysql -u root  ← 用root用戶登錄MySQL服務(wù)器

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

成都創(chuàng)新互聯(lián)長期為上千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為歷下企業(yè)提供專業(yè)的網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計歷下網(wǎng)站改版等技術(shù)服務(wù)。擁有十多年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

mysql> select user,host,password from mysql.user;  ← 查看用戶信息
+------+------------------------------+---------------+
| user | host          | password |
+------+------------------------------+---------------+
| root | localhost        |       | ← root密碼為空
| root | sample.centospub.com  |       | ← root密碼為空
|   | sample.centospub.com |       |
|   | localhost       |       |
+------+------------------------------+---------------+
4 rows in set (0.00 sec)

mysql> set password for root@localhost=password('在這里填入root密碼');  ← 設(shè)置root密碼
Query OK, 0 rows affected (0.01 sec)

mysql> set password for root@'sample.centospub.com'=password('在這里填入root密碼');  ← 設(shè)置root密碼
Query OK, 0 rows affected (0.01 sec)

mysql> select user,host,password from mysql.user;  ← 查看用戶信息
+------+--------------------------------+--------------------------+
| user | host          | password     |
+------+--------------------------------+--------------------------+
| root | localhost        |19b68057189b027f | ← root密碼被設(shè)置
| root | sample.centospub.com   |19b68057189b027f | ← root密碼被設(shè)置
|    | sample.centospub.com   |          |
|    | localhost        |          |
+------+--------------------------------+--------------------------+
4 rows in set (0.01 sec)

mysql> exit  ← 退出MySQL服務(wù)器
Bye


+++++++然后,測試一下root密碼有沒有生效。
[root@sample ~]#mysql -u root ← 通過空密碼用root登錄

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ← 出現(xiàn)此錯誤信息說明密碼設(shè)置成功

[root@localhost ~]#mysql -u root -h sample.centospub.com  ← 通過空密碼用root登錄

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ← 出現(xiàn)此錯誤信息說明密碼設(shè)置成功

[root@sample ~]#mysql -u root -p ← 通過密碼用root登錄
Enter password: ← 在這里輸入密碼

Welcome to the MySQL monitor. Commands end with ; or g. ← 確認(rèn)用密碼能夠成功登錄
Your MySQL connection id is 5 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> exit
Bye

[root@sample ~]# mysql -u root -h sample.centospub.com -p  ← 通過密碼用root登錄
Enter password:  ← 在這里輸入密碼

Welcome to the MySQL monitor. Commands end with ; or g.  ← 確認(rèn)用密碼能夠成功登錄
Your MySQL connection id is 6 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>exit ← 退出MySQL服務(wù)器
Bye
++++++++++++++[2] 刪除匿名用戶
在MySQL剛剛被安裝后,存在用戶名、密碼為空的用戶。這使得數(shù)據(jù)庫服務(wù)器有無需密碼被登錄的可能性。為消除隱患,將匿名用戶刪除。
[root@sample ~]#mysql -u root -p ← 通過密碼用root登錄
Enter password: ← 在這里輸入密碼

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 7 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> select user,host from mysql.user;  ← 查看用戶信息
+------+----------------------------+
| user | host         |
+------+----------------------------+
|   | localhost       |
| root | localhost       |
|   | sample.centospub.com |
| root | sample.centospub.com  |
+------+----------------------------+
4 rows in set (0.02 sec)

mysql> delete from mysql.user where user='';  ← 刪除匿名用戶
Query OK, 2 rows affected (0.17 sec)

mysql> select user,host from mysql.user;  ← 查看用戶信息
+------+----------------------------+
| user | host         |
+------+----------------------------+
| root | localhost      |
| root | sample.centospub.com |
+------+----------------------------+
2 rows in set (0.00 sec)

mysql> exit  ← 退出MySQL服務(wù)器
Bye
+++++++++++++++++++[3] 刪除測試用數(shù)據(jù)庫

在MySQL被安裝后,存在名為test的空數(shù)據(jù)庫,將它刪除。這里要注意的是,系統(tǒng)默認(rèn)的還有一個名為mysql的數(shù)據(jù)庫,它用于系統(tǒng)管理,所以請不要刪除。
[root@sample ~]# mysql -u root -p  ← 通過密碼用root登錄
Enter password:  ← 在這里輸入密碼
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> show databases;  ← 查看系統(tǒng)已存在的數(shù)據(jù)庫
+-------------+
| Database |
+-------------+
| mysql   |
| test   |
+------------+
2 rows in set (0.02 sec)

mysql> drop database test;  ← 刪除名為test的空數(shù)據(jù)庫
Query OK, 0 rows affected (0.07 sec)

mysql> show databases;  ← 查看系統(tǒng)已存在的數(shù)據(jù)庫
+-------------+
| Database |
+-------------+
| mysql   |  ← 確認(rèn)名為test的數(shù)據(jù)庫被刪除,已不存在
+-------------+
1 row in set (0.00 sec)

mysql> exit  ← 退出MySQL服務(wù)器
Bye

++++++++++++
測試MySQL
下面對MySQL進(jìn)行測試。包括建立新用戶,以及用對關(guān)系性數(shù)據(jù)庫進(jìn)行數(shù)據(jù)庫操作的指令來試著建立數(shù)據(jù)庫及數(shù)據(jù)表。這里,新建用戶以centospub為例。


[root@sample ~]#mysql -u root -p ← 通過密碼用root登錄
Enter password: ← 在這里輸入密碼

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> grant all privileges on test.* to centospub@localhost identified by '在這里定義密碼';  ← 建立對test數(shù)據(jù)庫有完全操作權(quán)限的名為centospub的用戶
Query OK, 0 rows affected (0.03 sec)

mysql> select user from mysql.user where user='centospub';  ← 確認(rèn)centospub用戶的存在與否
+---------+
| user  |
+---------+
| centospub |  ← 確認(rèn)centospub已經(jīng)被建立
+---------+
1 row in set (0.01 sec)

mysql> exit  ← 退出MySQL服務(wù)器
Bye

[root@sample ~]# mysql -u centospub -p  ← 用新建立的centospub用戶登錄MySQL服務(wù)器
Enter password:  ← 在這里輸入密碼

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 10 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> create database test;  ← 建立名為test的數(shù)據(jù)庫
Query OK, 1 row affected (0.00 sec)

mysql> show databases;  ← 查看系統(tǒng)已存在的數(shù)據(jù)庫
+-------------+
| Database |
+-------------+
| test    |
+-------------+
1 row in set (0.00 sec)

mysql> use test  ← 連接到數(shù)據(jù)庫
Database changed

mysql> create table test(num int, name varchar(50));  ← 在數(shù)據(jù)庫中建立表
Query OK, 0 rows affected (0.03 sec)

mysql> show tables;  ← 查看數(shù)據(jù)庫中已存在的表
+-------------------+
| Tables_in_test |
+-------------------+
| test     |
+-------------------+
1 row in set (0.01 sec)

mysql> insert into test values(1,'Hello World!');  ← 插入一個值到表中
Query OK, 1 row affected (0.02 sec)

mysql> select * from test;  ← 查看數(shù)據(jù)庫中的表的信息
+------+-------------------+
| num | name      |
+------+-------------------+
| 1   | Hello World! |
+------+-------------------+
1 row in set (0.00 sec)

mysql> update test set name='Hello Everyone!';  ← 更新表的信息,賦予新的值
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from test;  ← 查看數(shù)據(jù)庫中的表的信息
+------+----------------------+
| num | name      |
+------+----------------------+
| 1   | Hello Everyone! |  ← 確認(rèn)被更新到新的值
+------+----------------------+
1 row in set (0.01 sec)

mysql> delete from test where num=1;  ← 刪除表內(nèi)的值
Query OK, 1 row affected (0.00 sec)

mysql> select * from test;  ← 確認(rèn)刪除結(jié)果
Empty set (0.01 sec)

mysql> drop table test;  ← 刪除表
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;  ← 查看表信息
Empty set (0.00 sec)  ← 確認(rèn)表已被刪除

mysql> drop database test;  ← 刪除名為test的數(shù)據(jù)庫
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;  ← 查看已存在的數(shù)據(jù)庫
Empty set (0.01 sec)  ← 確認(rèn)test數(shù)據(jù)庫已被刪除(這里非root用戶的關(guān)系,看不到名為mysql的數(shù)據(jù)庫)

mysql> exit  ← 退出MySQL服務(wù)器
Bye

當(dāng)前題目:linux下MySQL初始環(huán)境設(shè)定
本文路徑:http://www.chinadenli.net/article16/ieoggg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號品牌網(wǎng)站設(shè)計網(wǎng)站收錄網(wǎng)站改版域名注冊外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司