程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQL相關,mysql

MySQL相關,mysql

編輯:MySQL綜合教程

MySQL相關,mysql


1.進入安裝目錄

cd E:\ZYXDocument\Software\mariadb-10.0.20-win32\bin

2.安裝mysql服務
將E:\ZYXDocument\Software\mariadb-10.0.20-win32\my.ini 放入 C:\Windows中


mysqld --install mysql --defaults-file="E:\ZYXDocument\Software\mariadb-10.0.20-win32\my.ini"

mysqld --install mysql --defaults-file="E:/ZYXDocument/Software/mysql-5.6.25/my.ini"


mysqld --defaults-file="E:/ZYXDocument/Software/mysql-5.7.11/my.ini" --initialize-insecure

mysqld --install mysql --defaults-file="E:/ZYXDocument/Software/mysql-5.7.11/my.ini"


Host
User

 

3.啟動mysql數據庫服務

net start mysql

4.停止mysql數據庫服務

net stop mysql

5.刪除mysql數據庫服務
mysqld remove mysql

6、修改mysql數據庫的root密碼(初始為空)

方法1: 用SET PASSWORD命令

    mysql -u root

    mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('gis');

方法2:用mysqladmin

    mysqladmin -u root password "gis"

    如果root已經設置過密碼,采用如下方法

    mysqladmin -u root password oldpass "gis"

方法3: 用UPDATE直接編輯user表

    mysql -u root

    mysql> use mysql;

    mysql> UPDATE user SET Password = PASSWORD('gis') WHERE user = 'root';

    mysql> FLUSH PRIVILEGES;

在丟失root密碼的時候,可以這樣

    mysqld_safe --skip-grant-tables&

    mysql -u root mysql

    mysql> UPDATE user SET password=PASSWORD("gis") WHERE user='root';

    mysql> FLUSH PRIVILEGES;

7、設置root權限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'gis';


SET GLOBAL max_allowed_packet = 2*1024*1024*10;

DELETE p.*
FROM st_rsvr_r p
LEFT JOIN st_stbprp_b pp
ON p.stcd = pp.stcd
WHERE pp.stnm IS NULL
COMMIT;

 

SET PASSWORD FOR 'root'@'%' = PASSWORD('gis');

 

-----------------------------------------------------------------------------------------

空間查詢相關操作

ALTER TABLE test_gis_station_hb ADD shape GEOMETRY AFTER lttd;


UPDATE test_gis_station_hb SET shape=GEOMFROMTEXT(CONCAT('POINT(', CAST(lgtd AS CHAR(20)), ' ', CAST(lttd AS CHAR(20)) ,')'))


SELECT ASTEXT(shape) shape, stcd FROM test_gis_station_hb


-----------------------------------------------------------


MYSQL查詢重復記錄的方法很多,下面就為您介紹幾種最常用的MYSQL查詢重復記錄的方法,希望對您學習MYSQL查詢重復記錄方面能有所幫助。

1、查找表中多余的重復記錄,重復記錄是根據單個字段(peopleId)來判斷

select * from people  
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)

 
2、刪除表中多余的重復記錄,重復記錄是根據單個字段(peopleId)來判斷,只留有rowid最小的記錄

delete from people  
where peopleId in (select peopleId from people group by peopleId   having count(peopleId) > 1)  
and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)  


3、查找表中多余的重復記錄(多個字段)

select * from vitae a  
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)  


4、刪除表中多余的重復記錄(多個字段),只留有rowid最小的記錄

delete from vitae a  
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)  
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)  


5、查找表中多余的重復記錄(多個字段),不包含rowid最小的記錄

select * from vitae a  
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)  
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1) 


---------------------------------------------------------------------------------------------

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved