Connect to mysql using macjdbc

Source: Internet
Author: User

1. Download The jdbc driver:

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

2. Add the jdbc jar package to the libs directory of the project and build path.

2. Modify the environment variable: export PATH =/usr/local/mysql/bin/: $ {PATH}

3. No Password for root @ localhost by default

4. Change the password:

Command Line: mysqladmin-u root-p password root

Commands in the MYSQL environment:

Mysql> UPDATE mysql. user SET password = PASSWORD ('new password') WHERE User = 'root ';

Mysql> flush privileges;

5. Restart mysql

/Library/StartupItems/MySQLCOM restart

Stop mysql

/Library/StartupItems/MySQLCOM stop

6. Go to test

Mysql-u root-proot

Use test

7. Create a new test table

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

8. Insert Test Data

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

Insert into table1 values ('pengk', 123456 );

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

Insert into table1 values ('pj, 123456 );

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

9. write code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.