日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

mysql学习--基本使用

發(fā)布時(shí)間:2024/8/26 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql学习--基本使用 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一旦安裝完畢,MySQL 服務(wù)器應(yīng)該自己主動(dòng)啟動(dòng)。

sudo start mysql #手動(dòng)的話這樣啟動(dòng) sudo stop mysql #手動(dòng)停止

當(dāng)你改動(dòng)了配置文件后,你須要重新啟動(dòng) mysqld 才干使這些改動(dòng)生效。

要想檢查 mysqld 進(jìn)程是否已經(jīng)開啟,能夠使用以下的命令:

pgrep mysqld

假設(shè)進(jìn)程開啟。這個(gè)命令將會(huì)返回該進(jìn)程的 id。

?

MySQL配置文件:/etc/mysql/my.cnf ,當(dāng)中指定了數(shù)據(jù)文件存放路徑

datadir = /var/lib/mysql

假設(shè)你創(chuàng)建了一個(gè)名為 test 的數(shù)據(jù)庫(kù)。那么這個(gè)數(shù)據(jù)庫(kù)的數(shù)據(jù)會(huì)存放到 /var/lib/mysql/test 文件夾下。

?

?

進(jìn)入MySQL

mysql -u root -p

(輸入mysql的root密碼)

qii@ubuntu:~$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with?; or \g. Your MySQL connection id is 37 Server version: 5.1.41-3ubuntu12.3 (Ubuntu)Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

改動(dòng) MySQL 的管理員密碼:

sudo mysqladmin -u root password newpassword。

?

查看當(dāng)前用戶擁有的數(shù)據(jù)庫(kù):

mysql> show databases
??? -> ;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
+--------------------+
3 rows in set (0.19 sec)

查看當(dāng)前用戶能夠用的數(shù)據(jù)庫(kù):

mysql> show databases
??? -> ;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
+--------------------+
3 rows in set (0.19 sec)

mysql> show tables
??? -> ;
ERROR 1046 (3D000): No database selected
mysql> select table_name from user_tables;
ERROR 1046 (3D000): No database selected
mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

?

選擇一個(gè)當(dāng)前數(shù)據(jù)庫(kù):

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

查看當(dāng)前數(shù)據(jù)庫(kù)中的表:
mysql> show tables
??? -> ;
+---------------------------+
| Tables_in_mysql?????????? |
+---------------------------+
| columns_priv????????????? |
| db??????????????????????? |
| event???????????????????? |
| func????????????????????? |
| general_log?????????????? |
| help_category???????????? |
| help_keyword????????????? |
| help_relation???????????? |
| help_topic??????????????? |
| host????????????????????? |
| ndb_binlog_index????????? |
| plugin??????????????????? |
| proc????????????????????? |
| procs_priv??????????????? |
| proxies_priv????????????? |
| servers?????????????????? |
| slow_log????????????????? |
| tables_priv?????????????? |
| time_zone???????????????? |
| time_zone_leap_second???? |
| time_zone_name??????????? |
| time_zone_transition????? |
| time_zone_transition_type |
| user????????????????????? |
+---------------------------+
24 rows in set (0.00 sec)

?查看一個(gè)表的具體信息:

mysql> describe servers;
+-------------+----------+------+-----+---------+-------+
| Field?????? | Type???? | Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+
| Server_name | char(64) | NO?? | PRI |???????? |?????? |
| Host??????? | char(64) | NO?? |???? |???????? |?????? |
| Db????????? | char(64) | NO?? |???? |???????? |?????? |
| Username??? | char(64) | NO?? |???? |???????? |?????? |
| Password??? | char(64) | NO?? |???? |???????? |?????? |
| Port??????? | int(4)?? | NO?? |???? | 0?????? |?????? |
| Socket????? | char(64) | NO?? |???? |???????? |?????? |
| Wrapper???? | char(64) | NO?? |???? |???????? |?????? |
| Owner?????? | char(64) | NO?? |???? |???????? |?????? |
+-------------+----------+------+-----+---------+-------+
9 rows in set (0.04 sec)

?

轉(zhuǎn)載于:https://www.cnblogs.com/xfgnongmin/p/10715303.html

總結(jié)

以上是生活随笔為你收集整理的mysql学习--基本使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。