search
Homephp教程php手册PHP学习mysql课件 高级篇第1/2页

PHP学习mysql课件 高级篇第1/2页

Jun 13, 2016 pm 12:28 PM
mysqlphpandclosurestart upstudyaccountdatabaseserveruserofadministratormaintainResponsibilitiesadvanced

   数据库管理员的职责
  服务器的启动与关闭
  用户帐户维护
  日志文件维护
  数据库的备份与拷贝
  服务器的优化
  数据库管理系统的软件更新
  数据目录的安全性
  服务器的安全性
  灾难恢复
  预防性维护
``````````````````````````````````````````````````
    数据库的启动与关闭
1、数据库的启动:
方法一:使用service 命令启动MySQL
    # service mysqld start
    // mysqld是MySQL的守护进程,通过运行它来启动MySQL服务。
方法二:使用mysqld脚本启动MySQL
    # /etc/init.d/mysqld start
方法三:使用safe_mysqld实用程序启动MySQL服务,此方法可以使用相关参数
    # safe_mysqld&
    使用&符号将safe_mysqld放在后台运行。
```````````````````````````````````````````````````````````
校验MySQL是否被启动:
      # service mysqld status
  //返回如下信息,表示已经启动
      mysqld (pid 1663) is running...
  //1663是mysqld运行的进程号,可能根据不同系统运行的进程数量而不同
若需要重新启动MySQL可以使用如下命令之一:
      # service mysqld restart
  # /etc/init.d/mysqld restart
````````````````````````````````````````````````````````
2、数据库的关闭:
    可以使用如下命令之一:
    #  service mysqld stop
    #  /etc/init.d/mysqld stop
    #  /mysqladmin shutdown


    MySQL管理
修改root管理密码
方法一:
mysql>set password for ‘帐号'@‘主机' = old_password(‘密码');
update mysql.user set password = old_password(‘密码') where host = ‘主机' and user = ‘帐号';
flush privileges;
方法二:
mysqladmin  password  'crq'

用户密码
对于MySQL密码可以使用PASSWORD()和ENCRYPT()函数进行加密
  mysql>select PASSWORD(“alex”);
    “23fc96e064be0017”
  注:ENCRYPT()在Windows上不可用

方法三:使用update语句和password()函数将root口令设置为crp。
  mysql> update user set password=password('crq')
             -> where user='root';
      //返回如下信息,表示授权表user修改成功
      Query OK, 2 row affected (0.09 sec)
      Rows matched:2  changed:2  warnings: 0
 注意:由此种方法是直接对授权表user进行修改,而服务器只有在启动时才会加载授权表中的权限设置,因此必须要使用客户端程序mysql环境下的flush privileges命令或使用管理工具mysqladmin的flush-privileges子命令通知服务器重新加载授权表。
  mysql>  flush privileges;   //此时即生效可以使用。
```````````````````````````````````````````````````````````````````
    改变数据库存储路径

在Window下,MySQL的所有数据库都保存在“%mysqlroor%\data”目录下。
停止MySQL服务
修改%systemroor%\my.ini文件
  [mysqld]
  datadir=D:/data
将原目录中的所有文件和文件夹内容,全部移动到新的目录D:/data目录中。
重启MySQL服务

修改MySQL字符集
找到MySQL配置文件my.ini,一般在C:\window\my.ini。
在my.ini文件里面加上“default-character-set=gbk #”或gb2312,utf8
重启MySQL服务

删除匿名用户:
    myslq>  delete from user where user=' ';
    //返回如下信息,表示匿名用户删除成功
    Query OK, 2 row affected (0.03 sec)

添加新的用户权限:
使用grant语句用于授予用户权限,
  语法:  
  GRANT priv_type[(column_list)][,priv_type[(column_list)]…]
    ON {*.* | * | db_name.* | db_name.tabl_name | db_name}
    TO user_name [IDENTIFIED BY ‘password']
      [,user_name [IDENTIFIED BY ‘password']…]
      [WITH GRANT OPTION]


创建新用户
制定用户名,最长允许为16个英文字符
制定允许该用户可以访问的数据库和表
制定允许该用户对数据库做什么的操作
制定允许该用户从哪些主机/IP进行远程连接
制定允许该用户对其他用户进行授权或取消授权

例如:添加一个可以从本地主机连接到MySQL服务器的超级用户crq,但是连接时必须使用口令crqpass
    mysql> grant all on *.* to crq@localhost identfied by 'crqpass' with grant option;
    //返回如下信息,表明权限设置成功
    Query OK, 0 rows affected (0.02 sec)
例如:使用同样的方法添加一个可以从其他任何地方连接到MySQL服务器的超级用户crq,但是连接时必须使用口令crqpass
    mysql> grant all on *.* to crq@'%' identified by ‘crqpass' with grant option;

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.