易截截图软件、单文件、免安装、纯绿色、仅160KB

MySql基础知识(经典版)

 
一、mysql 的管理
1
、连接
Mysql
格式: mysql -h主机地址 -u用户名 -p用户密码
例1:连接到本机上的MYSQL。
首先在打开DOS窗口,然后进入目录 mysqlbin,再键入命令mysql -uroot -p,回车后提示你输密码,如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中了,MYSQL的提示符是:mysql>
例2:连接到远程主机上的MYSQL。假设远程主机的IP为:110.110.110.110,用户名为root,密码为abcd123。则键入以下命令:
mysql -h110.110.110.110 -uroot -pabcd123
(注:u与root可以不用加空格,其它也一样)
2
、退出MYSQL命令: exit (回车)
3

修改密码
格式:mysqladmin -u用户名 -p旧密码 password 新密码
1) mysqladmin -u用户名 -p旧密码 password 新密码 
    例:mysqladmin -u root password 21century
    注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
 2)直接修改user表的root用户口令:
   mysql> user mysql;
   mysql> update user set pasword=password('21century') where user='root';
   mysql> flush privileges;
   注:flush privileges的意思是强制刷新内存授权表,否则用的还是缓冲中的口令。
4
、测试密码是否修改成功
   1)不用密码登录
  [root@test1 local]# mysql
  ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
  显示错误,说明密码已经修改。
  2)用修改后的密码登录
  [root@test1 local]# mysql -u root -p
  Enter password: (输入修改后的密码21century)
  Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 177 to server version: 3.23.48
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql>
  成功!
  这是通过mysqladmin命令修改口令,也可通过修改库来更改口令 
5、增加新用户
(注意:和上面不同,下面的因为是MYSQL环境中的命令,所以后面都带一个分号作为命令结束符)
格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"
例1、增加一个用户test1密码为abc,让他可以在任何主机上登录,并对所有数据


相关文档:

MySql常用命令

  启动:net start mySql;
  进入:mysql -u root -p/mysql -h localhost -u root -p databaseName;
  列出数据库:show databases;
  选择数据库:use databaseName;
  列出表格:show tables;
  显示表格列的属性:show columns from tableName;
  建立数据库:source fileNa ......

11 advanced MySQL questions

 

Explain MySQL architecture
. - The front layer
takes care of network connections and security authentications, the
middle layer does the SQL query parsing, and then the query is handled
off to the storage engine. A storage engine could be either a default
one supp ......

.\mysql\user is marked as crashed 解决办法

 
I found a solution to anyone else who may be having this problem.
First start mysql using skip grant tables
root@ns1 [/var/lib/mysql/mysql]# service mysql start --skip-grant-tables
Starting MySQL [ OK ]
now with mysql started, you can repair the mysql/user table
root@ns1 [/var/lib/mysql ......

用java连接MySql数据库

 一个简单示例--
1,准备:MySQL数据库驱动包【mysql-connector-java-5.1.10-bin.jar】导入
2,创建测试连接主程序
package mysqlConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class JdbcDemo {
public static void main(String[] args) {
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号