之前在配置MySQL做为Hive的Metastore时,曾安装过MySQL,但可惜的是并没有记录整个过程。现在忽然发现MySQL不能使用了,试过网上的很多方法都不行,所以决定将MySQL卸载掉,重新安装,并记录整个过程以备再次重装MySQL。首先使用下面的命令查询已经安装的MyS
之前在配置MySQL做为Hive的Metastore时,曾安装过MySQL,但可惜的是并没有记录整个过程。现在忽然发现MySQL不能使用了,试过网上的很多方法都不行,所以决定将MySQL卸载掉,重新安装,并记录整个过程以备再次重装MySQL。首先使用下面的命令查询已经安装的MySQL:
[root@hadoop local]# rpm -qa | grep -i mysql MySQL-client-5.6.21-1.rhel5.x86_64 MySQL-server-5.6.21-1.el6.x86_64
卸载MySQL使用下面的命令,由于其它应用可能依赖MySQL,所以使用了--nodeps强制卸载MySQL:
[root@hadoop local]# rpm -e --nodeps MySQL-server-5.6.21-1.el6.x86_64 [root@hadoop local]# rpm -e --nodeps MySQL-client-5.6.21-1.rhel5.x86_64
要想完全清理掉所有与MySQL相关的文件,可以使用find命令进行查找,然后删除。在完成MySQL的卸载后,下面进行安装,通常情况下只需要安装server和client即可:
[root@hadoop hadoop]# ls My* MySQL-client-5.6.21-1.rhel5.x86_64.rpm MySQL-server-5.6.21-1.el6.x86_64.rpm
然后按照下面的命令安装server和client:
[root@hadoop hadoop]# rpm -ivh MySQL-server-5.6.21-1.el6.x86_64.rpm Preparing... ########################################### [100%] 1:MySQL-server ########################################### [100%] A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER ! You will find that password in '/root/.mysql_secret'. You must change that password on your first connect, no other statement but 'SET PASSWORD' will be accepted. See the manual for the semantics of the 'password expired' flag. Also, the account for the anonymous user has been removed. In addition, you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test database. This is strongly recommended for production servers. New default config file was created as /usr/my.cnf and will be used by default by the server when you start it.You may edit this file to change server settings [root@hadoop hadoop]# rpm -ivh MySQL-client-5.6.21-1.rhel5.x86_64.rpm Preparing... ########################################### [100%] 1:MySQL-client ########################################### [100%]
成功安装MySQL后,根据输出信息可知默认为root用户生成了随机密码并保存在/root/.mysql_secret文件中,可以在登录MySQL后进行修改。同时移除了之前很多版本中存在的匿名用户(匿名用户指user表中user字段为空的用户即为匿名用户,该用户的密码也为空)。其它信息还有在生产环境中如何移除测试数据库等。默认将MySQL安装在/var/lib/mysql中,在此次安装中不会对默认设置做任何修改。
可以使用/etc/init.d/mysql脚本启动、停止、重启MySQL数据库,该脚本的具体用法如下:
[root@hadoop ~]# /etc/init.d/mysql Usage: mysql {start|stop|restart|reload|force-reload|status} [ MySQL server options ]
现在修改root的初始密码,首先要使用该初始密码登录到MySQL中,具体命令为:
mysql –u root –p
在登录MySQL后,使用下面的命令为root用户设置新密码:
mysql> set password = password('root'); Query OK, 0 rows affected (0.01 sec)
剩下的最后一步就是将MySQL设置为随系统启动而启动,虽然实现这一点的方式有很多种,但推荐按照官方文档的方式:
[root@hadoop ~]# chkconfig --levels 235 mysql on

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

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.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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),

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment