mysql学习--基本使用
一旦安裝完畢,MySQL 服務器應該自己主動啟動。
sudo start mysql #手動的話這樣啟動 sudo stop mysql #手動停止當你改動了配置文件后,你須要重新啟動 mysqld 才干使這些改動生效。
要想檢查 mysqld 進程是否已經開啟,能夠使用以下的命令:
pgrep mysqld假設進程開啟。這個命令將會返回該進程的 id。
?
MySQL配置文件:/etc/mysql/my.cnf ,當中指定了數據文件存放路徑
datadir = /var/lib/mysql假設你創建了一個名為 test 的數據庫。那么這個數據庫的數據會存放到 /var/lib/mysql/test 文件夾下。
?
?
進入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>改動 MySQL 的管理員密碼:
sudo mysqladmin -u root password newpassword。?
查看當前用戶擁有的數據庫:
mysql> show databases
??? -> ;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| performance_schema |
+--------------------+
3 rows in set (0.19 sec)
查看當前用戶能夠用的數據庫:
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)
?
選擇一個當前數據庫:
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
查看當前數據庫中的表:
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)
?查看一個表的具體信息:
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)
?
轉載于:https://www.cnblogs.com/xfgnongmin/p/10715303.html
總結
以上是生活随笔為你收集整理的mysql学习--基本使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用jenkins实现监控嵌入式设备稳定
- 下一篇: TT 安装 之 AIX