Home > Database > Mysql Tutorial > body text

macjdbc连接mysql_MySQL

WBOY
Release: 2016-06-01 13:13:49
Original
949 people have browsed it

1.下载jdbc驱动:

http://dev.mysql.com/downloads/connector/j/

2.加入jdbc的jar包至项目的libs目录并build path

2.修改环境变量:export PATH=/usr/local/mysql/bin/:${PATH}

3.默认root@localhost没有密码

4.修改密码:

命令行:mysqladmin -u root -p password root

MYSQL环境中的命令:

mysql> UPDATE mysql.user SET password=PASSWORD(’新密码’) WHERE User=’root’;

mysql> FLUSH PRIVILEGES;

5.重启mysql

/Library/StartupItems/MySQLCOM/MySQLCOM restart

停止mysql

/Library/StartupItems/MySQLCOM/MySQLCOM stop

6.进入test

mysql -u root -proot

use test

7.新建一张测试表

create table table1 (username varchar(20) primary key,password integer);

8插入测试数据

insert into table1 values('yyz',123456);

insert into table1 values('pengkv',123456);

insert into table1 values('yjj',123456);

insert into table1 values('pj',123456);

insert into table1 values('cl',123456);

9.书写代码

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template