初用MySQL Mysql示例庫 Navicat15
查詢MySQl版本
Mysql shell > select version();
右括號,not version
查看初始密碼
MySQl首次啟動會創建“超級管理員賬號”root@localhost,初始密碼存盤在日志檔案中,通過grep搜索并查看:
grep 'temporary password' /var/log/mysqld.log
進入mysql
mysql -u root -p
通過鍵入密碼(上一步查詢到的密碼)的方式以root身份進入mysql
請注意,這里的root身份是指mysql系統中的“超級管理員”root,而不是作業系統的root,因為如下圖,只密碼正確,以es用戶也可以以root用戶身份登入mysql

修改默認密碼
alter user 'root'@'localhost' identified by 'yourselfPassword'
如果出現
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
則說明你自己設定的密碼沒有到達MySQL默認的最低標準---字母、數字、符號
出現
Query OK, 0 rows affected (0.00 sec)
則說明修改成功
官網示例資料庫
https://dev.mysql.com/doc/index-other.html
(期中world_x database是world database的“升級版”)
world_X示例庫
官方Doc鏈接
https://dev.mysql.com/doc/world-x-setup/en/world-x-setup-installation.html
-
下載
通過
wget --spider測驗下載連接wget --spider https://downloads.mysql.com/docs/world_x-db.tar.gz若如下顯示則說明連接有效

再下載tgz壓縮包到想要的位置
wget https://downloads.mysql.com/docs/world_x-db.tar.gz -
解壓tgz
-
source命令匯入資料庫
source /yourPathTo/world_x.sql登入MySQL shell后直接使用source命令會默認以
.sql檔案的檔案名創建同名的資料庫,手動起名的方式詳見此處 -
檢驗:

sakila
-
sakila是一個擁有很多table的資料庫,用于當做租借光碟的商店所使用Mysql的資料庫,涉及電影、演員、類別、客戶、付款等等
-
下載并解壓
wget https://downloads.mysql.com/docs/sakila-db.tar.gz -
進入Mysql shell,使用sakila-schema.sql創建資料庫結構,使用sakila-data.sql填充資料
Mysql -u root -p source /yourPathTp/sakila-db/sakila-schema.sql source /yourPathTp/sakila-db/sakila-data.sql -
優秀的使用示例
https://dev.mysql.com/doc/sakila/en/sakila-usage.html
employee data (large dataset, includes data and test/verification suite)
-
員工樣本資料庫提供了六個單獨的表,總共包含400萬條記錄,該結構與各種存盤引擎型別兼容,通過包含的資料檔案,還提供了對磁區表的支持,
-
下載并解壓(zip)
wget https://github.com/datacharmer/test_db/archive/master.zip yum install -y unzip zip unzip master.zip -
需要在employee.sql所在檔案夾執行匯入命令
mysql -t -u root -p < employees.sql如果不是在employee.sql所在檔案夾執行,或者在已經開啟的Mysql shell使用source方式匯入,會產生如下報錯:
ERROR: Failed to open file 'load_salaries1.dump', error: 2 ERROR: Failed to open file 'load_salaries2.dump', error: 2 ERROR: Failed to open file 'load_salaries3.dump', error: 2 ERROR: Failed to open file 'show_elapsed.sql', error: 2 -
如圖則匯入成功:

更多匯入匯出方式
https://www.runoob.com/w3cnote/linux-mysql-import-export-data.html
Navicat15
navicat 15 安裝:
https://www.cnblogs.com/kkdaj/p/12794804.html
解決navicat創建連接 1130 error
mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Gwj332017&' WITH GRANT OPTION;
FLUSH PRIVILEGES
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/26216.html
標籤:MySQL
上一篇:請教一下高效地資料庫存盤方法
