MySQL相关

2018-06-17 22:58:11来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

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) 


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

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:MySQL中授权(grant)和撤销授权(revoke

下一篇:mysql,命令导入\导出表结构或数据