




已閱讀5頁,還剩1頁未讀, 繼續免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
Mysql數據庫1、JDBC設置/登記JDBC驅動程序 Class.forName(org.gjt.mm.mysql.Driver).newInstance(); /連接數據庫 sqlConn = java.sql.DriverManager.getConnection(jdbc:mysql:/localhost:3306/xyw,xyw,1234); /創建語句對象 sqlStmt = sqlConn.createStatement(); /獲取來自客戶端的數據 String ls_sql=select * from tbl_name; rs = sqlStmt.executeQuery(ls_sql);2、授予服務器小程序訪問權mysqlgrant all on xyw.tbl_name to xywlocalhost identified by 1234;3、創建數據庫mysqlcreate database xyw;4、打開數據庫mysqluse xyw;5、建表6、Mysql/Mysqlc的用法 可以用Help獲得61、Execute a SQL script file. Takes a file name as an argument 使用Source命令,例如:mysql source g:project.sqlgrant all on xyw.tbl_project to xywlocalhost identified by 1234;關閉數據庫C:mysqlbinmysqladmin -u root shutdown要設置MySQL中的root口令,在你安裝MySQL的目錄的bin子目錄下輸入下面的命令(包括引號):mysqladmin -u root password your new passwordC:mysqlbinmysqladmin -u root password your_password使用MYSQLmysql -h localhost -u root pmysql -user=root mydata -p(mydata是數據庫名稱)1、增加了密碼后的登錄格式如下: mysql -u root -p 2、修改登錄密碼 1) mysqladmin -u用戶名 -p舊密碼 password 新密碼 例:mysqladmin -u root password 21century 注:因為開始時root沒有密碼,所以-p舊密碼一項就可以省略了。 2)直接修改user表的root用戶口令: mysql user mysql; mysql update user set pasword=password(21century) where user=root; mysql flush privileges; 注:flush privileges的意思是強制刷新內存授權表,否則用的還是緩沖中的口令。3、測試密碼是否修改成功 1)不用密碼登錄roottest1 local# mysqlERROR 1045: Access denied for user: rootlocalhost (Using password: NO)顯示錯誤,說明密碼已經修改。2)用修改后的密碼登錄roottest1 local# mysql -u root -p Enter password: (輸入修改后的密碼21century)Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 177 to server version: 3.23.48 Type help; or h for help. Type c to clear the buffer.mysql成功!這是通過mysqladmin命令修改口令,也可通過修改庫來更改口令 4、啟動和停止 啟動:Mysql從3.23.15版本開始作了改動,默認安裝后服務要用mysql用戶來啟動,不允許root用戶啟動。 如果非要用root用戶來啟動,必須加上-user=root參數 (./safe_mysqld -user=root &) 停止:mysqladmin -u root -p shutdown 5、導出meeting數據庫: mysqldump -uroot -p21century meeting db_meeting.sql 導人dbname數據庫 mysqldump -uroot -p21century dbname xxx.sql 導入數據庫還可用類似于oracle中my_script.sql的方式一次執行大量sql語句,這在使用mysqldump不起作用時非常有用。 例:#./mysql -uroot -p mysqld -installTo remove a server that is installed as a service, first stop it if it is running. Then use the -remove option to remove it: shell mysqld -removeAdding New Users to MySQLFirst, use the mysql program to connect to the server as the MySQL root user: shell mysql -user=root mysqlThen you can add new users by issuing GRANT statements: mysql GRANT ALL PRIVILEGES ON *.* TO montylocalhost - IDENTIFIED BY some_pass WITH GRANT OPTION;mysql GRANT ALL PRIVILEGES ON *.* TO monty% - IDENTIFIED BY some_pass WITH GRANT OPTION;mysql GRANT RELOAD,PROCESS ON *.* TO adminlocalhost;mysql GRANT USAGE ON *.* TO dummylocalhost;These GRANT statements set up three new users: monty A full superuser who can connect to the server from anywhere, but who must use a password some_pass to do so. Note that we must issue GRANT statements for both montylocalhost and monty%. If we dont add the entry with localhost, the anonymous user entry for localhost that is created by mysql_install_db takes precedence when we connect from the local host, because it has a more specific Host field value and thus comes earlier in the user table sort order. admin A user who can connect from localhost without a password and who is granted the RELOAD and PROCESS administrative privileges. This allows the user to execute the mysqladmin reload, mysqladmin refresh, and mysqladmin flush-* commands, as well as mysqladmin processlist . No database-level privileges are granted. (They can be granted later by issuing additional GRANT statements.) dummy A user who can connect without a password, but only from the local host. No privileges are granted-the USAGE privilege type allows you to create a user with no privileges. It has the effect of setting all the global privileges to N. It is assumed that you will grant specific privileges to the account later. 或者mysql INSERT INTO user - VALUES(localhost,monty,PASSWORD(some_pass), - Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y);You can stop the MySQL server by executing this command: shell C:mysqlbinmysqladmin -u root shutdown6、數據庫的備份:退回到DOS:mysqlquitd:mysqlbin使用如下命令對數據庫abccs進行備份:mysqldump-optabccsabccs.dbbabccs.dbb就是你的數據庫abccs的備份文件。7、用批處理方式使用MySQL:首先建立一個批處理文件mytest.sql,內容如下:useabccs;select*frommytable;selectname,sexfrommytablewherename=abccs;在DOS下運行如下命令:d:mysqlbinmysqlmytest.sql在屏幕上會顯示執行結果。如果想看結果,而輸出結果很多,則可以用這樣的命令:mysqlmytest.sql|more
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 城市公共交通車輛運營監管協議
- 生態漁業資源開發協議條款
- 一年級最美的風景作文9篇
- 垃圾填埋場土壤污染防治與修復技術
- 出差人員接待與分配表格
- 小學班級文化建設的實踐與探索
- 財務管理支出表格
- 股票交易信息跟蹤表
- 金融業客戶信息安全保密合作協議
- 王維與鹿柴:詩文解析與賞析
- NB-T32036-2017光伏發電工程達標投產驗收規程
- 2024年吉林省中考歷史試卷真題(含答案)
- 人教部編版三年級下冊語文【選擇題】專項復習訓練真題100題(附答案解析)
- 國際標準舞智慧樹知到期末考試答案章節答案2024年成都體育學院
- 互聯網與營銷創新智慧樹知到期末考試答案章節答案2024年華東師范大學
- 四川省成都市溫江縣2023-2024學年八下物理期末監測試題及答案解析
- 內科學(腎臟-內分泌-血液)智慧樹知到期末考試答案章節答案2024年溫州醫科大學
- 食品安全與日常飲食智慧樹知到期末考試答案章節答案2024年中國農業大學
- 100以內進退位加減法口算題每天60道
- MOOC 嵌入式軟件設計-大連理工大學 中國大學慕課答案
- 永久基本農田儲備區劃定技術方案
評論
0/150
提交評論