MySQL 数据库命令的实际应用实例
以下的文章主要介绍的是MySQL 数据库命令的实际应用,其中包括如何正确提升某个用户的相关权限,如何从相关的备份文件中获得恢复的实际操作步骤,以下就是文章的具体内容描述,望你会有所收获。 1:提升某个用户的权限 dbname 指定用户 grantallon*.*tosfsuse
以下的文章主要介绍的是MySQL 数据库命令的实际应用,其中包括如何正确提升某个用户的相关权限,如何从相关的备份文件中获得恢复的实际操作步骤,以下就是文章的具体内容描述,望你会有所收获。
1:提升某个用户的权限
dbname 指定用户
<ol class="dp-xml"><li class="alt"><span><span>grant all on *.* to sfsuser@'%'; </span></span></li></ol>
2:从备份文件中恢复
<ol class="dp-xml"><li class="alt">MySQL<span> –usfsuser –p111111 dbname </span><span></span> </li></ol>
3:登陆远程MySQL数据库
<ol class="dp-xml"><li class="alt">MySQL<span> -h10.0.0.1 -usfsuser -p111111; </span> </li></ol>
4:设置数据默认字符集
<ol class="dp-xml"><li class="alt"><span><span>vi /etc/my.cof </span></span></li></ol>
找到客户端配置[client] 在下面添加
default-character-set=utf8 默认字符集为utf8
在找到[MySQLd] 添加
default-character-set=utf8 默认字符集为utf8
<ol class="dp-xml"><li class="alt"><span><span class="attribute">init_connect</span><span>=</span><span class="attribute-value">'SET NAMES utf8'</span><span> </span></span></li></ol>
重新启动MySQL数据库
<ol class="dp-xml"> <li class="alt"><span>/etc/init.d/MySQL stop </span></li> <li> <span>/etc/init.d/</span>MySQL<span> start </span> </li> </ol>
进入MySQL 运行
<ol class="dp-xml"> <li class="alt"><span><span>show variables like 'character%'; </span></span></li> <li><span>+--------------------------+----------------------------+ </span></li> <li class="alt"><span>| Variable_name | Value | </span></li> <li><span>+--------------------------+----------------------------+ </span></li> <li class="alt"><span>| character_set_client | utf8 | </span></li> <li><span>| character_set_connection | utf8 | </span></li> <li class="alt"><span>| character_set_database | utf8 | </span></li> <li><span>| character_set_filesystem | binary | </span></li> <li class="alt"><span>| character_set_results | utf8 | </span></li> <li><span>| character_set_server | utf8 | </span></li> <li class="alt"><span>| character_set_system | utf8 | </span></li> <li> <span>| character_sets_dir | /usr/share/</span>MySQL<span>/charsets/ | </span> </li> <li class="alt"><span>+--------------------------+----------------------------+ </span></li> </ol>
5:慢查询日志
在MySQL数据库配置文件my.cnf中增加
log-slow-queries=/var/lib/MySQL/slowquery.log (指定日志文件存放位置,可以为空,系统会给一个缺省的文件host_name-slow.log)
long_query_time=2 ((包括所有5.*系列,5.1.21之前)的慢查询日志默认是以秒为单位的,其后的为毫秒 记录超过的时间,默认为10s)
log-queries-not-using-indexes (log下来没有使用索引的query,特别要注意检查慢查询的时候最好不要打开该控制,如果要打开控制最好装microtime slow query的补丁,免得你误会一些记录是慢查询.比如对整个表做count(*)的操作和其他没用索引但是速度很快的操作)
log-long-format (如果设置了,所有没有使用索引的查询也将被记录)
重启数据库以后用SHOW VARIABLES;查看对应的字段是否生效;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.
