{"id":670,"date":"2015-06-13T14:13:48","date_gmt":"2015-06-13T06:13:48","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=670"},"modified":"2016-07-17T10:59:23","modified_gmt":"2016-07-17T02:59:23","slug":"%e5%b8%b8%e7%94%a8%e7%9a%84sql%e8%af%ad%e5%8f%a5","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/centos\/2015\/06\/13\/141348670.html","title":{"rendered":"\u5e38\u7528\u7684SQL\u8bed\u53e5"},"content":{"rendered":"<p><strong>1\u3001\u8fde\u63a5Mysql<\/strong><\/p>\n<pre lang=\"mysql\" line=\"1\">mysql -h\u4e3b\u673a\u5730\u5740 -u\u7528\u6237\u540d \uff0dp\u7528\u6237\u5bc6\u7801<\/pre>\n<p><strong>2\u3001\u4fee\u6539\u5bc6\u7801<\/strong><\/p>\n<pre lang=\"mysql\" line=\"1\">mysqladmin -u\u7528\u6237\u540d -p\u65e7\u5bc6\u7801 password \u65b0\u5bc6\u7801<\/pre>\n<p><strong>3\u3001\u589e\u52a0\u65b0\u7528\u6237<\/strong><\/p>\n<pre lang=\"mysql\" line=\"1\">grant select on \u6570\u636e\u5e93.* to \u7528\u6237\u540d@\u767b\u5f55\u4e3b\u673a identified by \u201c\u5bc6\u7801\u201d<\/pre>\n<p><strong>4\u3001\u521b\u5efa\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u6ce8\u610f\uff1a\u521b\u5efa\u6570\u636e\u5e93\u4e4b\u524d\u8981\u5148\u8fde\u63a5Mysql\u670d\u52a1\u5668<\/p>\n<pre lang=\"mysql\" line=\"1\">create database <\u6570\u636e\u5e93\u540d><\/pre>\n<p>\u4f8b1\uff1a\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3axhkdb\u7684\u6570\u636e\u5e93<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> create database xhkdb;<\/pre>\n<p>\u4f8b2\uff1a\u521b\u5efa\u6570\u636e\u5e93\u5e76\u5206\u914d\u7528\u6237<\/p>\n<pre lang=\"mysql\" line=\"1\">\u2460CREATE DATABASE \u6570\u636e\u5e93\u540d;\n\n\u2461GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON \u6570\u636e\u5e93\u540d.* TO \u6570\u636e\u5e93\u540d@localhost IDENTIFIED BY '\u5bc6\u7801';\n\n\u2462SET PASSWORD FOR '\u6570\u636e\u5e93\u540d'@'localhost' = OLD_PASSWORD('\u5bc6\u7801');<\/pre>\n<p>\u4f9d\u6b21\u6267\u884c3\u4e2a\u547d\u4ee4\u5b8c\u6210\u6570\u636e\u5e93\u521b\u5efa\u3002\u6ce8\u610f\uff1a\u4e2d\u6587 \u201c\u5bc6\u7801\u201d\u548c\u201c\u6570\u636e\u5e93\u201d\u662f\u6237\u81ea\u5df1\u9700\u8981\u8bbe\u7f6e\u7684\u3002<\/p>\n<p><strong>5\u3001\u663e\u793a\u6570\u636e\u5e93<\/strong><!--more--><\/p>\n<p>\u547d\u4ee4\uff1ashow databases \uff08\u6ce8\u610f\uff1a\u6700\u540e\u6709\u4e2as\uff09<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> show databases;<\/pre>\n<p><strong>6\u3001\u5220\u9664\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u547d\u4ee4\uff1adrop database <\u6570\u636e\u5e93\u540d><br \/>\n\u4f8b\u5982\uff1a\u5220\u9664\u540d\u4e3a xhkdb\u7684\u6570\u636e\u5e93<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> drop database xhkdb;<\/pre>\n<p>\u4f8b\u5b501\uff1a\u5220\u9664\u4e00\u4e2a\u5df2\u7ecf\u786e\u5b9a\u5b58\u5728\u7684\u6570\u636e\u5e93<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> drop database drop_database;\nQuery OK, 0 rows affected (0.00 sec)<\/pre>\n<p>\u4f8b\u5b502\uff1a\u5220\u9664\u4e00\u4e2a\u4e0d\u786e\u5b9a\u5b58\u5728\u7684\u6570\u636e\u5e93<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> drop database drop_database;\nERROR 1008 (HY000): Can't drop database 'drop_database'; database doesn't exist\n\/\/\u53d1\u751f\u9519\u8bef\uff0c\u4e0d\u80fd\u5220\u9664'drop_database'\u6570\u636e\u5e93\uff0c\u8be5\u6570\u636e\u5e93\u4e0d\u5b58\u5728\u3002\nmysql> drop database if exists drop_database;\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\/\/\u4ea7\u751f\u4e00\u4e2a\u8b66\u544a\u8bf4\u660e\u6b64\u6570\u636e\u5e93\u4e0d\u5b58\u5728\nmysql> create database drop_database;\nQuery OK, 1 row affected (0.00 sec)\nmysql> drop database if exists drop_database;\/\/if exists \u5224\u65ad\u6570\u636e\u5e93\u662f\u5426\u5b58\u5728\uff0c\u4e0d\u5b58\u5728\u4e5f\u4e0d\u4ea7\u751f\u9519\u8bef\nQuery OK, 0 rows affected (0.00 sec)<\/pre>\n<p><strong>7\u3001\u8fde\u63a5\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u547d\u4ee4\uff1a use <\u6570\u636e\u5e93\u540d><\/p>\n<p>\u4f8b\u5982\uff1a\u5982\u679cxhkdb\u6570\u636e\u5e93\u5b58\u5728\uff0c\u5c1d\u8bd5\u5b58\u53d6\u5b83\uff1a<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> use xhkdb;\nDatabase changed<\/pre>\n<p><strong>8\u3001\u5f53\u524d\u9009\u62e9\u7684\u6570\u636e\u5e93<\/strong><\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> select database();<\/pre>\n<p>MySQL\u4e2dSELECT\u547d\u4ee4\u7c7b\u4f3c\u4e8e\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u91cc\u7684print\u6216\u8005write\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u6765\u663e\u793a\u4e00\u4e2a\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u3001\u6570\u5b66\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u7b49\u7b49\u3002\u5982\u4f55\u4f7f\u7528MySQL\u4e2dSELECT\u547d\u4ee4\u7684\u7279\u6b8a\u529f\u80fd\uff1f<\/p>\n<p>\u663e\u793aMYSQL\u7684\u7248\u672c<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> select version(); <\/pre>\n<p>\u663e\u793a\u5f53\u524d\u65f6\u95f4<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> select now(); <\/pre>\n<p>\u663e\u793a\u5e74\u6708\u65e5<\/p>\n<pre lang=\"mysql\" line=\"1\">SELECT DAYOFMONTH(CURRENT_DATE);  \nSELECT MONTH(CURRENT_DATE); \nSELECT YEAR(CURRENT_DATE); <\/pre>\n<p>\u663e\u793a\u5b57\u7b26\u4e32<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> SELECT \"welecome to my blog!\"; <\/pre>\n<p>\u5f53\u8ba1\u7b97\u5668\u7528<\/p>\n<pre lang=\"mysql\" line=\"1\">select ((4 * 4) \/ 10 ) + 25; <\/pre>\n<p>\u4e32\u63a5\u5b57\u7b26\u4e32<\/p>\n<pre lang=\"mysql\" line=\"1\">select CONCAT(f_name, \" \", l_name) <\/pre>\n<p>\u6ce8\u610f\uff1a\u8fd9\u91cc\u7528\u5230CONCAT()\u51fd\u6570\uff0c\u7528\u6765\u628a\u5b57\u7b26\u4e32\u4e32\u63a5\u8d77\u6765\u3002\u53e6\u5916\uff0c\u6211\u4eec\u8fd8\u7528\u5230\u4ee5\u524d\u5b66\u5230\u7684AS\u7ed9\u7ed3\u679c\u5217&#8217;CONCAT(f_name, &#8221; &#8220;, l_name)&#8217;\u8d77\u4e86\u4e2a\u5047\u540d\u3002<\/p>\n<p><strong>9\u3001\u521b\u5efa\u6570\u636e\u8868<\/strong><\/p>\n<pre lang=\"mysql\" line=\"1\">create table <\u8868\u540d> ( <\u5b57\u6bb5\u540d1> <\u7c7b\u578b1> [,..<\u5b57\u6bb5\u540dn> <\u7c7b\u578bn>]);<\/pre>\n<p>\u4f8b\u5982\uff0c\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3aMyClass\u7684\u8868\uff0c                   <\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> create table MyClass(\n> id int(4) not null primary key auto_increment,\n> name char(20) not null,\n> sex int(4) not null default '0',\n> degree double(16,2));<\/pre>\n<p><strong>10\u3001\u5220\u9664\u6570\u636e\u8868<\/strong><\/p>\n<pre lang=\"mysql\" line=\"1\">drop table <\u8868\u540d>\n\u4f8b\u5982\uff1a\u5220\u9664\u8868\u540d\u4e3a MyClass \u7684\u8868\nmysql> drop table MyClass;<\/pre>\n<p><strong>11\u3001\u8868\u63d2\u5165\u6570\u636e<\/strong><\/p>\n<p>\u547d\u4ee4\uff1ainsert into <\u8868\u540d> [( <\u5b57\u6bb5\u540d1>[,..<\u5b57\u6bb5\u540dn > ])] values ( \u503c1 )[, ( \u503cn )]<\/p>\n<p>\u4f8b\u5982\uff1a\u5f80\u8868 MyClass\u4e2d\u63d2\u5165\u4e8c\u6761\u8bb0\u5f55, \u8fd9\u4e8c\u6761\u8bb0\u5f55\u8868\u793a\uff1a\u7f16\u53f7\u4e3a1\u7684\u540d\u4e3aTom\u7684\u6210\u7ee9\u4e3a96.45, \u7f16\u53f7\u4e3a2 \u7684\u540d\u4e3aJoan \u7684\u6210\u7ee9\u4e3a82.99\uff0c \u7f16\u53f7\u4e3a3 \u7684\u540d\u4e3aWang \u7684\u6210\u7ee9\u4e3a96.5\u3002<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);<\/pre>\n<p>\u6ce8\u610f\uff1ainsert into\u6bcf\u6b21\u53ea\u80fd\u5411\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\u3002<\/p>\n<p><strong>12\u3001\u67e5\u8be2\u8868\u4e2d\u7684\u6570\u636e<\/strong><\/p>\n<p>1)\u3001\u67e5\u8be2\u6240\u6709\u884c<br \/>\n\u547d\u4ee4\uff1a select <\u5b57\u6bb51\uff0c\u5b57\u6bb52\uff0c...> from < \u8868\u540d > where < \u8868\u8fbe\u5f0f ><br \/>\n\u4f8b\u5982\uff1a\u67e5\u770b\u8868 MyClass \u4e2d\u6240\u6709\u6570\u636e<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> select * from MyClass;<\/pre>\n<p>2)\u3001\u67e5\u8be2\u524d\u51e0\u884c\u6570\u636e<br \/>\n\u4f8b\u5982\uff1a\u67e5\u770b\u8868 MyClass \u4e2d\u524d2\u884c\u6570\u636e<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> select * from MyClass order by id limit 0,2;<\/pre>\n<p>select\u4e00\u822c\u914d\u5408where\u4f7f\u7528\uff0c\u4ee5\u67e5\u8be2\u66f4\u7cbe\u786e\u66f4\u590d\u6742\u7684\u6570\u636e\u3002<\/p>\n<p><strong>13\u3001\u5220\u9664\u8868\u4e2d\u6570\u636e<\/strong><\/p>\n<p>\u547d\u4ee4\uff1adelete from \u8868\u540d where \u8868\u8fbe\u5f0f<\/p>\n<p>\u4f8b\u5982\uff1a\u5220\u9664\u8868 MyClass\u4e2d\u7f16\u53f7\u4e3a1 \u7684\u8bb0\u5f55<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> delete from MyClass where id=1;<\/pre>\n<p><strong>14\u3001\u4fee\u6539\u8868\u4e2d\u6570\u636e<\/strong><\/p>\n<p>\u8bed\u6cd5\uff1aupdate \u8868\u540d set \u5b57\u6bb5=\u65b0\u503c,\u2026 where \u6761\u4ef6<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> update MyClass set name='Mary' where id=1;<\/pre>\n<p>\u4f8b\u5b501\uff1a\u5355\u8868\u7684MySQL UPDATE\u8bed\u53e5\uff1a<\/p>\n<pre lang=\"mysql\" line=\"1\">UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition] [ORDER BY ...] [LIMIT row_count]<\/pre>\n<p>\u4f8b\u5b502\uff1a\u591a\u8868\u7684UPDATE\u8bed\u53e5\uff1a<\/p>\n<pre lang=\"mysql\" line=\"1\">UPDATE [LOW_PRIORITY] [IGNORE] table_references SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition]<\/pre>\n<p>UPDATE\u8bed\u6cd5\u53ef\u4ee5\u7528\u65b0\u503c\u66f4\u65b0\u539f\u6709\u8868\u884c\u4e2d\u7684\u5404\u5217\u3002SET\u5b50\u53e5\u6307\u793a\u8981\u4fee\u6539\u54ea\u4e9b\u5217\u548c\u8981\u7ed9\u4e88\u54ea\u4e9b\u503c\u3002WHERE\u5b50\u53e5\u6307\u5b9a\u5e94\u66f4\u65b0\u54ea\u4e9b\u884c\u3002\u5982\u679c\u6ca1\u6709WHERE\u5b50\u53e5\uff0c\u5219\u66f4\u65b0\u6240\u6709\u7684\u884c\u3002\u5982\u679c\u6307\u5b9a\u4e86ORDER BY\u5b50\u53e5\uff0c\u5219\u6309\u7167\u88ab\u6307\u5b9a\u7684\u987a\u5e8f\u5bf9\u884c\u8fdb\u884c\u66f4\u65b0\u3002LIMIT\u5b50\u53e5\u7528\u4e8e\u7ed9\u5b9a\u4e00\u4e2a\u9650\u503c\uff0c\u9650\u5236\u53ef\u4ee5\u88ab\u66f4\u65b0\u7684\u884c\u7684\u6570\u76ee\u3002<\/p>\n<p><strong>15\u3001\u589e\u52a0\u5b57\u6bb5<\/strong><\/p>\n<p>\u547d\u4ee4\uff1aalter table \u8868\u540d add\u5b57\u6bb5 \u7c7b\u578b \u5176\u4ed6;<\/p>\n<p>\u4f8b\u5982\uff1a\u5728\u8868MyClass\u4e2d\u6dfb\u52a0\u4e86\u4e00\u4e2a\u5b57\u6bb5passtest\uff0c\u7c7b\u578b\u4e3aint(4)\uff0c\u9ed8\u8ba4\u503c\u4e3a0<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> alter table MyClass add passtest int(4) default '0'<\/pre>\n<p>\u52a0\u7d22\u5f15<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> alter table \u8868\u540d add index \u7d22\u5f15\u540d (\u5b57\u6bb5\u540d1[\uff0c\u5b57\u6bb5\u540d2 \u2026]);\nmysql> alter table employee add index emp_name (name);<\/pre>\n<p>\u52a0\u4e3b\u5173\u952e\u5b57\u7684\u7d22\u5f15<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> alter table \u8868\u540d add primary key (\u5b57\u6bb5\u540d);\nmysql> alter table employee add primary key(id);<\/pre>\n<p>\u52a0\u552f\u4e00\u9650\u5236\u6761\u4ef6\u7684\u7d22\u5f15<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> alter table \u8868\u540d add unique \u7d22\u5f15\u540d (\u5b57\u6bb5\u540d);\nmysql> alter table employee add unique emp_name2(cardnumber);<\/pre>\n<p>\u5220\u9664\u67d0\u4e2a\u7d22\u5f15<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> alter table \u8868\u540d drop index \u7d22\u5f15\u540d;\nmysql>alter table employee drop index emp_name;<\/pre>\n<p>\u589e\u52a0\u5b57\u6bb5\uff1a<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> ALTER TABLE table_name ADD field_name field_type;<\/pre>\n<p>\u4fee\u6539\u539f\u5b57\u6bb5\u540d\u79f0\u53ca\u7c7b\u578b\uff1a<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;<\/pre>\n<p>\u5220\u9664\u5b57\u6bb5\uff1a<\/p>\n<pre lang=\"mysql\" line=\"1\">MySQL ALTER TABLE table_name DROP field_name;<\/pre>\n<p><strong>16\u3001\u4fee\u6539\u8868\u540d<\/strong><\/p>\n<p>\u547d\u4ee4\uff1arename table \u539f\u8868\u540d to \u65b0\u8868\u540d;<\/p>\n<p>\u4f8b\u5982\uff1a\u5728\u8868MyClass\u540d\u5b57\u66f4\u6539\u4e3aYouClass<\/p>\n<pre lang=\"mysql\" line=\"1\">mysql> rename table MyClass to YouClass;<\/pre>\n<p>\u5f53\u4f60\u6267\u884c RENAME \u65f6\uff0c\u4f60\u4e0d\u80fd\u6709\u4efb\u4f55\u9501\u5b9a\u7684\u8868\u6216\u6d3b\u52a8\u7684\u4e8b\u52a1\u3002\u4f60\u540c\u6837\u4e5f\u5fc5\u987b\u6709\u5bf9\u539f\u521d\u8868\u7684 ALTER \u548c DROP \u6743\u9650\uff0c\u4ee5\u53ca\u5bf9\u65b0\u8868\u7684 CREATE \u548c INSERT \u6743\u9650\u3002<br \/>\n\u5982\u679c\u5728\u591a\u8868\u66f4\u540d\u4e2d\uff0cMySQL \u906d\u9047\u5230\u4efb\u4f55\u9519\u8bef\uff0c\u5b83\u5c06\u5bf9\u6240\u6709\u88ab\u66f4\u540d\u7684\u8868\u8fdb\u884c\u5012\u9000\u66f4\u540d\uff0c\u5c06\u6bcf\u4ef6\u4e8b\u7269\u9000\u56de\u5230\u6700\u521d\u72b6\u6001\u3002<br \/>\nRENAME TABLE \u5728 MySQL 3.23.23 \u4e2d\u88ab\u52a0\u5165\u3002<\/p>\n<p><strong>17\u3001\u5907\u4efd\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u547d\u4ee4\u5728DOS\u7684\\\\mysql\\\\bin\u76ee\u5f55\u4e0b\u6267\u884c<\/p>\n<p>1.\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93<br \/>\n\u5bfc\u51fa\u6587\u4ef6\u9ed8\u8ba4\u662f\u5b58\u5728mysql\\bin\u76ee\u5f55\u4e0b<\/p>\n<pre lang=\"mysql\" line=\"1\">mysqldump -u \u7528\u6237\u540d -p \u6570\u636e\u5e93\u540d > \u5bfc\u51fa\u7684\u6587\u4ef6\u540d\nmysqldump -u user_name -p123456 database_name > outfile_name.sql<\/pre>\n<p>2.\u5bfc\u51fa\u4e00\u4e2a\u8868<\/p>\n<pre lang=\"mysql\" line=\"1\">mysqldump -u \u7528\u6237\u540d -p \u6570\u636e\u5e93\u540d \u8868\u540d> \u5bfc\u51fa\u7684\u6587\u4ef6\u540d\nmysqldump -u user_name -p database_name table_name > outfile_name.sql<\/pre>\n<p>3.\u5bfc\u51fa\u4e00\u4e2a\u6570\u636e\u5e93\u7ed3\u6784<\/p>\n<pre lang=\"mysql\" line=\"1\">\/\/ -d \u6ca1\u6709\u6570\u636e \u2013add-drop-table \u5728\u6bcf\u4e2acreate\u8bed\u53e5\u4e4b\u524d\u589e\u52a0\u4e00\u4e2adrop table\nmysqldump -u user_name -p -d \u2013add-drop-table database_name > outfile_name.sql<\/pre>\n<p>4.\u5e26\u8bed\u8a00\u53c2\u6570\u5bfc\u51fa<\/p>\n<pre lang=\"mysql\" line=\"1\">mysqldump -uroot -p \u2013default-character-set=latin1 \u2013set-charset=gbk \u2013skip-opt database_name > outfile_name.sql<\/pre>\n<p>\u4f8b\u5982\uff0c\u5c06aaa\u5e93\u5907\u4efd\u5230\u6587\u4ef6back_aaa\u4e2d\uff1a<\/p>\n<pre lang=\"mysql\" line=\"1\">[root@test1 root]# cd\u3000\/home\/data\/mysql\n[root@test1 mysql]# mysqldump -u root -p --opt aaa > back_aaa\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u8fde\u63a5Mysql mysql -h\u4e3b\u673a\u5730\u5740 -u\u7528\u6237\u540d \uff0dp\u7528\u6237\u5bc6\u7801 2\u3001\u4fee\u6539\u5bc6\u7801 mysqladmin -u\u7528\u6237\u540d -p\u65e7\u5bc6\u7801 password \u65b0\u5bc6\u7801 3\u3001\u589e\u52a0\u65b0\u7528\u6237 grant select on \u6570\u636e\u5e93.* to \u7528\u6237\u540d@\u767b\u5f55\u4e3b\u673a identified by \u201c\u5bc6\u7801\u201d 4\u3001\u521b\u5efa\u6570\u636e\u5e93 \u6ce8\u610f\uff1a\u521b\u5efa\u6570\u636e\u5e93\u4e4b\u524d\u8981\u5148\u8fde\u63a5Mysql\u670d\u52a1\u5668 create database \u4f8b1\uff1a\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3axhkdb\u7684\u6570\u636e\u5e93 mysql> create database xhkdb; \u4f8b2\uff1a\u521b\u5efa\u6570\u636e\u5e93\u5e76\u5206\u914d\u7528\u6237 \u2460CREATE DATABASE \u6570\u636e\u5e93\u540d; \u2461GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON \u6570\u636e\u5e93\u540d.* TO \u6570\u636e\u5e93\u540d@localhost IDENTIFIED BY &#8216;\u5bc6\u7801&#8217;; \u2462SET PASSWORD FOR &#8216;\u6570\u636e\u5e93\u540d&#8217;@&#8217;localhost&#8217; = OLD_PASSWORD(&#8216;\u5bc6\u7801&#8217;); \u4f9d\u6b21\u6267\u884c3\u4e2a\u547d\u4ee4\u5b8c\u6210\u6570\u636e\u5e93\u521b\u5efa\u3002\u6ce8\u610f\uff1a\u4e2d\u6587 \u201c\u5bc6\u7801\u201d\u548c\u201c\u6570\u636e\u5e93\u201d\u662f\u6237\u81ea\u5df1\u9700\u8981\u8bbe\u7f6e\u7684\u3002 5\u3001\u663e\u793a\u6570\u636e\u5e93<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[22],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-centos","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}