Difference: 1. MySQL is a relational database; while Redis is a non-relational database. 2. MySQL is used to persistently store data to the hard disk, which is powerful but slow; while Redis is used to store frequently used data in the cache and has fast reading speed. 3. MySQL data is stored on disk; Redis data is stored in memory. 4. MySQL’s commonly used data types include numerical values, date/time, and strings; Redis’s commonly used data types include strings, Hash, List, Set, and Zset.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
1. Mysql is arelational database
, mainly used to store persistent data and store data In a hard disk, the read speed is relatively slow.
2. Redis is a NOSQL database, that is,non-relational database
, and it is also a cache database, that is, data is stored inmemory
. The cached read speed is fast and can Greatly improves operating efficiency, but the storage time is limited.
1. As a stored relational database, the relative weakness of MySQL database is that every time a request is made to access the database, There areI/O operations
. If the database is accessed repeatedly and frequently, the following problems will occur:
(1)会在反复链接数据库上花费大量的时间,从而导致运行效率过慢 (2)反复的访问数据库也会导致数据库的负载过高,那么此时缓存的概念就衍生出来了
2. Redis is based on single thread, and Redis is more efficient because Redis is based on memory. operation, so theCPU is not the performance bottleneck
, the machine'smemory and bandwidth are the bottlenecks
of Redis.
The cache is thebuffer (cache) for data exchange
. When the browser performs a request, it will first search the cache and obtain it if it exists; otherwise, it will Access the database.
Benefits of caching:Fast reading speed
##Example:Redis database is a cache database , used to store frequently used data, thus reducing the number of database accesses and improving operating efficiency.
mysql video tutorial]
The above is the detailed content of What are the differences between MySQL and Redis?. For more information, please follow other related articles on the PHP Chinese website!