mysql

1. mysql启动

  mysqld --console

2. mysql关闭

  mysqladmin shutdown -uroot -proot

 

3. 免安装mysql配置:

  启动mysql: mysqld --skip-grant-tables(跳过安全校验), 修改mysql.user表里面的数据,最后flush privileges;

 mysql  jdbc连接代码

1             Class.forName("com.mysql.jdbc.Driver");
2 
3             Connection connection = null;
4             PreparedStatement preparedStatement = null;
5             ResultSet resultSet = null;
6             
7             connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "root");
8             preparedStatement = connection.prepareStatement("select host, user, password from user");

 

4. tomcat jdbc数据源JNDI配置

1       <Context docBase="java_ee" path="/java_ee" reloadable="true" source="org.eclipse.jst.jee.server:java_ee">
2         <Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource" 
3             driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/mysql" username="root" password="root" 
4             maxActive="30" maxIdle="30" maxWait="10000" />
5       </Context>

 

5. mysql导出:

mysqldump -uroot -proot --max_allowed_packet=1048576 --net_buffer_length=16384 --extended-insert=FALSE --default-character-set=utf8 --routines --events "g2mdb" >export2.sql

6. mysql权限赋予

>grant all privileges on *.* to 'root'@'%‘ identified by 'root';

>flush privileges;

 

6. update join多表更新

update nms_res_device A
inner join (select ifnull(max(severity), 0) maxLevel, deviceId from nms_alm_info where clearTime = '0000-00-00 00:00:00' and isClear != 2 group by deviceId) TEMP
on A.deviceId = TEMP.deviceId
set A.alarmLevel = TEMP.maxLevel;

你可能感兴趣的:(mysql)