mariadb使用总结
2015-05-23 22:01 ysf002 阅读(237) 评论(0) 收藏 举报1.service mariadb status/start/stop/restart
一系列的mariadb的常用命令
2.新增一个yangsf的用户,密码是yangsf,可以从本机或者任何一台机器上连接
GRANT ALL PRIVILEGES ON *.* TO 'yangsf'@'localhost' IDENTIFIED BY 'yangsf' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'yangsf'@'%' IDENTIFIED BY 'yangsf' WITH GRANT OPTION;
flush privileges;测试代码
try
{
Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.9:3306/test", "yangsf", "yangsf");
Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE a (id int not null primary key, value varchar(20))");
stmt.close();
connection.close();
}
catch (SQLException e) {
System.out.print(e.getSQLState());
// e.printStackTrace();
}
System.out.print("OK");
{
Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.9:3306/test", "yangsf", "yangsf");
Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE a (id int not null primary key, value varchar(20))");
stmt.close();
connection.close();
}
catch (SQLException e) {
System.out.print(e.getSQLState());
// e.printStackTrace();
}
System.out.print("OK");
3.登陆
mysql -h host -u user -p
4.查看数据库
mysql> SHOW DATABASES;
5.使用数据库
mysql> USE DATABASES;
6.查看数据库中表
mysql> show tables;
浙公网安备 33010602011771号