mysql的一些简单操作

来源:互联网 发布:中国有哪些著名公知 编辑:程序博客网 时间:2024/05/17 07:30

/usr/bin/mysqladmin -u root password 'new-password'   
/usr/bin/mysqladmin -u root -h test1 password 'new-password' (省略显示)  

1、数据库目录 
   /var/lib/mysql/ 
2、配置文件 
   /usr/share/mysql(mysql.server命令及配置文件) 
3、相关命令 
   /usr/bin(mysqladmin mysqldump等命令) 
4、启动脚本 
   /etc/rc.d/init.d/(启动脚本文件mysql的目录)
            mysqld
            使用rpm安装的方式,可能会出现以下情况, 直接键入Mysqld会出现以下提示
            -bash:mysqld:command not found
           应使用 ./mysql start 来启动
  
五、修改登录密码   
MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。  
1、命令   
usr/bin/mysqladmin -u root password 'new-password'   
格式:mysqladmin -u用户名 -p旧密码 password 新密码   
2、例子   
例1:给root加个密码123456。  
  键入以下命令 :
     [root@test1 local]# /usr/bin/mysqladmin -u root password 123456  
  注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。   
3、测试是否修改成功  

1)不用密码登录
[root@test1 local]# mysql
ERROR 1045: Access denied for user: (Using password: NO)
显示错误,说明密码已经修改。
2)用修改后的密码登录
[root@test1 local]# mysql -u root -p
Enter password: (输入修改后的密码123456) 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 4 to server version: 4.0.16-standard 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
mysql>    成功!    这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。  

注意:MySQL中每个命令后都要以分号;结尾。   
1、显示数据库    mysql> show databases; 
2、显示数据库中的表
mysql> use mysql; 
(打开库,对每个库进行操作就要打开此库,类似于foxpro )
Database changed 
mysql> show tables;  

0 0