MySQL basis

MySQL basis

basic steps to play with mysql

# 1) login mysql with root
     mysql -u root -p
# 2) update password for root (optional)
   
   
   
   
UPDATE mysql. user  SET password =PASSWORD( 'newPasswordFor Root 'WHERE  User = ' root ';
FLUSH  PRIVILEGES;

# 3) create a new user 'user1'

CREATE  USER user1 IDENTIFIED  BY  'my password '
# 4) grant all privileges for this user 
GRANT  ALL  PRIVILEGES  ON  *. *  TO  ' user1 '@ ' localhost ' IDENTIFIED  BY  ' my password '
FLUSH  PRIVILEGES;

# 5) create a database with char set utf-8

create  database mydatabase  character  set utf8;
set character_set_client =utf8;
set character_set_connection =utf8;
set character_set_database =utf8;
set character_set_results =utf8;
set character_set_server =utf8;


# 6) switch to a database
use mydatabase;
show tables;

# 7) Sample JDBC connection URL

jdbc:mysql: //localhost: 3306 /mydatabase?useUnicode =true &characterEncoding =utf - 8 &autoReconnect =true &failOverReadOnly =false


你可能感兴趣的:(MySQL basis)