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

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

Jun 13, 2016 pm 12:28 PM
mysql php and closure start up study account database server user of administrator maintain Responsibilities advanced

   数据库管理员的职责
  服务器的启动与关闭
  用户帐户维护
  日志文件维护
  数据库的备份与拷贝
  服务器的优化
  数据库管理系统的软件更新
  数据目录的安全性
  服务器的安全性
  灾难恢复
  预防性维护
``````````````````````````````````````````````````
    数据库的启动与关闭
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 of this Website
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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP's Current Status: A Look at Web Development Trends PHP's Current Status: A Look at Web Development Trends Apr 13, 2025 am 12:20 AM

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

PHP: The Foundation of Many Websites PHP: The Foundation of Many Websites Apr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

See all articles