標籤:command form redis fill sch sso import sys .gz
資料庫關係型資料庫(RDBMS):oracle mysql db2 sql server sybase...優點:容易理解、方便使用、資料一致、讀寫即時資料一致:事務要麼全部成功;要麼全部失敗;在我們資料庫中一個事務是由很多條sql語句組成,要麼全部執行成功,要麼全部失敗;這樣才能保證資料的一致性應用情境:1、對資料的一致性要求比較高(銀行的交易系統)2、對資料的即時性要求較高非關係型資料:【nosql】 Mongdb redis memcahe ..https://db-engines.com/en/rankingMysql資料庫的安裝:1、通過二進位包的方式安裝rpm:xxx.el6.x86_64.rpmglibc:Linux所有版本通用的一個二進位的軟體包。也是C的運行庫,幾乎所有的linux系統最底層的api介面,都會依賴glibc。優點:方便安裝缺點:不能自訂2、源碼包安裝 xxx.tar.gz三步曲 (配置編譯安裝)優點:靈活,可以自訂缺點:比較麻煩3、構建自己的rpm包優點:根據需求定址自己的rpm包,後續方便安裝缺點:前期的構建時間長,而且麻煩安裝:1、使用rpm包安裝1)redhat 自己的mysqlrpm包mysql.x86_64 5.1.71-1.el6mysql-bench.x86_64 5.1.71-1.el6mysql-connector-java.noarch 1:5.1.17-6.el6mysql-connector-odbc.x86_64 5.1.5r1144-7.el6mysql-devel.i686 5.1.71-1.el6mysql-devel.x86_64 5.1.71-1.el6mysql-libs.i686 5.1.71-1.el6mysql-server.x86_64 5.1.71-1.el6mysql-test.x86_64 5.1.71-1.el6php-mysql.x86_64 5.3.3-26.el6# rpm -ql mysql-server/etc/logrotate.d/mysqld 日誌輪轉檔案/etc/rc.d/init.d/mysqld 啟動指令碼/var/lib/mysql mysql的預設資料根目錄/var/log/mysqld.log 記錄檔/var/run/mysqld mysql進程目錄# rpm -ql mysql/usr/bin/mysql 用戶端命令/usr/bin/mysqladmin/usr/bin/mysqlbinlog/usr/bin/mysqlcheck/usr/bin/mysqldump/usr/bin/mysqlimport/usr/bin/mysqlshow啟動服務:# /etc/rc.d/init.d/mysqld start# service mysql start(啟動過程:)Initializing MySQL database: Installing MySQL system tables...OKFilling help tables...OK------以上2個ok說明資料庫初始化完畢To start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password ‘new-password‘/usr/bin/mysqladmin -u root -h node1.uplook.com password ‘new-password‘Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script![ OK ]Starting mysqld: [ OK ]後續配置:# /usr/bin/mysql_secure_installation 安全配置Change the root password? [Y/n] n... skipping.Remove anonymous users? [Y/n] n... skipping.Disallow root login remotely? [Y/n] n 生產環境中一般是不允許遠端存取... skipping.Remove test database and access to it? [Y/n] yReload privilege tables now? [Y/n] y# netstat -nltp|grep 3306tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 4739/mysqld# mysql -p123-----登入mysqlmysql> show databases 查看當前資料庫-> ;+--------------------+| Database |+--------------------+| information_schema || mysql |+--------------------+2 rows in set (0.00 sec)information_schema資料庫:對象資料資訊庫,一般儲存的是其他資料庫的相關資訊;裡面只有一個唯讀表,實際上是一個視圖,不是基本表,無法看到任何的相關檔案mysql資料庫:核心的庫test庫:測試庫-------------------------------------------------------------------------------------------------------------後續密碼設定:1、直接使用用戶端工具設定密碼# mysqladmin -u root password ‘123‘ 設定新密碼(第一次設定密碼)# mysqladmin -u root password ‘newpass‘ -p123 重新設定密碼# mysqladmin -u root password ‘mysql‘ -p ----(輸入passwd)2、使用sql語句直接更新表資訊、進入mysql:mysql> update user set password=password(456) where user=‘root‘ and host=‘localhost‘;mysql> flush privileges; 重新整理授權表或者mysql> flush privileges; 重新整理授權表mysql> set password for ‘root‘@‘localhost‘=password(‘123‘); 不需要重新整理授權表3、不知道原來的密碼1)修改設定檔/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf(如果以上設定檔有衝突,那麼以最後讀取到的為主)vim /etc/my.cnf[mysqld]skip-grant-tables 跳過授權表datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid#pid-file=/var/lib/mysql/mysqld.pid2)直接在後台安全進程啟動mysql# /usr/bin/mysqld_safe --skip-grant-tables &初始化:# /usr/bin/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf2、安裝mysql AB 官方的rpm包MySQL-server-5.6.19-1.el6.x86_64.rpmMySQL-client-5.6.19-1.el6.x86_64.rpmMySQL-devel-5.6.19-1.el6.x86_64.rpmMySQL-embedded-5.6.19-1.el6.x86_64.rpmMySQL-shared-5.6.19-1.el6.x86_64.rpmMySQL-shared-compat-5.6.19-1.el6.x86_64.rpmMySQL-test-5.6.19-1.el6.x86_64.rpm安裝前:# rpm -e mysql-server mysql mysql-libs --nodeps# rm -rf /var/lib/mysql/*# cd /var/lib/mysql/# rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm# cat ~/.mysql_secret ---------> 初始密碼# mysql_secure_installation...安裝過程出現的問題解決:錯誤提示:找不到/var/lib/mysql/mysql.sock解決:# service mysql start 3306監聽注意:pid檔案和sock檔案是在服務啟動後產生的;錯誤:mysql> show databases;ERROR 1820 (HY000): You must SET PASSWORD before executing this statementmysql> set password for ‘root‘@‘localhost‘=password(‘111‘);mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema |+--------------------+performance_schema:資料庫是mysql 5.5版本以後有的,收集作業系統效能相關的資訊mysql用戶端工具:-u:指定使用者-S:指定sock檔案-h:指定主機(ip|主機名稱)-e:外部執行sql-P:指定連接埠-p:指定密碼# mysql -p (預設是root使用者從localhost登入)# mysql -u xxx -P xxx -p說明:-p參數後面跟的密碼不能有空格;如果有空格就意味者訪問的是參數後面的資料庫# mysql -p 123Enter password:ERROR 1049 (42000): Unknown database ‘123‘# mysql -uroot -e ‘show databases;‘ -pEnter password:+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema |+--------------------+查看:>show databases -----查看資料庫的列表>use information_schema mysql----進入>show tables>select *from FILES
mysql-rpm包安裝