<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">ubuntu卸载mysql:</span>
1
sudo rm /var/lib/mysql/ -R
删除mysql的数据文件
2
sudo rm /etc/mysql/ -R
删除mqsql的配置文件
3
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
自动卸载mysql的程序
ubuntu安装mysql:
http://jingyan.baidu.com/article/425e69e6bbc6c7be14fc1640.html
终端使用mysql的常用语句:
mysql -u root -p 开启mysql
具体的使用:http://laozhao.blog.51cto.com/blog/25213/7653
jdbc与eclipse并用:
http://www.cnblogs.com/taoweiji/archive/2012/12/11/2812852.html
远程登录mysql的设置:
终端登陆mysql,执行一句sql:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.8' IDENTIFIED BY 'www.linuxidc.com' WITH GRANT OPTION;
其中'www.linuxidc.com'就是设定连接密码了,然后192.168.1.8就可以连接了,简单有效,不是任意主机都可连,也安全一些。
mysql -h192.168.70.129 -uroot -pwww.linuxidc.com 登录
如何设置mysql数据库的编码格式:
http://jingyan.baidu.com/article/03b2f78c68b0c15ea237ae8d.html
连接数据库的时候,设置获取数据的编码:
String url="jdbc:mysql://192.168.70.129:3306/test2?"
+"user=root&password=www.linuxidc.com&useUnicode=true&"
+"characterEncoding=UTF8";
再次用java写一下jdbc与mysql的连接:
package test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBC {
public static void main(String[] args) throws SQLException{
Connection conn=null;
String sql;
String url="jdbc:mysql://192.168.70.129:3306/test2?"
+"user=root&password=www.linuxidc.com&useUnicode=true&"
+"characterEncoding=UTF8";
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("成功加载MySQL驱动程序");
conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
sql="select * from me";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
System.out.println(rs.getString(1)+"\t"+rs.getString(2));
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
conn.close();
}
}
}