How to add mysql to Red Hat system
How to add mysql to the Red Hat system: first log in to the Red Hat system as the root user; then create the mysql user and mysql group; then set the data storage directory; finally enter the mysql directory, manually execute the database initialization script and Just make relevant configuration file modifications.
Recommended: "mysql video tutorial"
Compile and install MySQL in Redhat Red Hat system
0. Log in to the system as the root user and perform the following operations
to avoid some troubles, such as: after the installation is completed, the password cannot be set and the mysql library cannot be seen.
1. Decompress the universal binary compressed package to /usr/local according to the official requirements, and the directory name must be mysql
- Enter the compressed package directory, Execute the following command to decompress
tar xf mysql****.tar.gz -C /usr/local- Create link
cd /usr/local
ln -sv mysql* **** mysql
2. Create mysql user mysql group (those with more than 500 are not system users, and system users do not have home directories)
groupadd -r -g 306 mysql
useradd -r -g 306 -u 306 mysql
Enter the mysql directory, there is an INSTALL-BINARY file with specific installation instructions. .
3. Modify the owner group of all files in the mysql directory
chown -R mysql.mysql /usr/local/mysql/*
4. Set the data storage directory
- Create the data directory: (Specify as needed)
- Modify the data directory permissions:
chown -R mysql .mysql data directory (specify the owner group of the data directory is the mysql user mysql group)
chmod o-rx data directory (other users do not have any permissions)
Ensure that the owner group of the data directory is mysql , other users do not have any permissions
5. Enter the mysql directory and manually execute the database initialization script
scripts/mysql_install_db --user=mysql - -datadir=data directory
6. After the script is executed, change the owner of the mysql directory to root
chown -R root /usr/local/mysql /*
7. There is mysql.server (mysql startup script) in the mysql/support-files directory
- Copy and rename the script
cp support-files/mysql.server /etc/init.d/mysqld- Check whether mysqld has execution permission, if not, give execution permission
- Add mysqld to the service list
chkconfig --add mysqld- Check whether automatic startup is enabled
chkconfig --list mysqld (2 3 4 5 is on)
8, this Mysqld cannot be started yet, you need to modify the configuration file
- Default location: /etc/my.cnf
- The way mysql reads the configuration file is very unique
Mysql configuration file is fragmented and centralized (can be configured for multiple services)
[mysql]——客户端配置 [mysqld]——服务端配置 [client]——对所有的客户端程序都生效
- mysql reads the configuration file Sequence:
/etc/my.cnf --> /etc/mysql/my.cnf
--> $BASEDIR/my.cnf (usually the installation directory)
--> ~ /.my.cnf (the configuration file in the user’s home directory, even if the mysql user does not have a home directory, search it again)
#If there is a conflict between the four configuration files found, the last One shall prevail (the latter one overwrites the previous one
Mysql can run even without any configuration files. A bunch of default configuration files are provided in the support-files directory
- Copy a configuration file to /etc/my.cnf
cp support-files/my-large.cnf /etc/my.cnf
- Edit and modify the configuration file
vi /etc/my.cnf- Add the data directory configuration information to the [mysqld] fragment, it is very important
datadir = /data directory
9. Start the mysqld service
service mysqld start
View the startup status
netstat -tnlp
10. Enter the mysql database
Execute mysql and find that the command cannot be found
Check ls /usr/local/mysql/bin/ and find that there is a mysql command
Need to add the mysql command to the system directory
Create a script File:
vi /etc/profile.d/mysql.sh
Add export PATH=$PATH:/usr/local/mysql/bin
Save and exit
Log in again and execute mysql again. Enter the mysql database
11. The mysql server maintains two types of variables
- Server variables: Define the operating characteristics of the MySQL server
View command: show global variables [like 'data%'] (used during tuning)- Status variables: Save the statistical data when the MySQL server is running
View command: show global status [like 'datadir'] (real-time monitoring Use)
12. Set password
[Method 1] Execute at the mysql prompt
mysql>set password for 'username'@ 'host'=password('password');
After modifying user information, reread the authorization table
mysql>flush privileges;
[方法二]在Linux命令提示符下执行
# mysqladmin -uUsername -hHost -p password 'password'(如果没有密码可以省略-p)
[方法三]修改mysql库中的user表
update user set Password=password("password") where user="user" and host="***"
创建mysql的root用户远程访问(对所有库.所有表)
mysql>grant all privileges on . to 'root'@'192.16.%.%' identified by "password";
重读授权表
mysql>flush privileges;
[方法四]安装完之后提示的密码修改方式:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
13、将mysql帮助文档添加至帮助命令
vi /etc/man.config
添加一行
MANPATH /usr/local/mysql/man
保存退出
14、创建数据库并指定字符集
CREATE DATABASE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
15、创建用户用于SqlYog登录
# 创建一个本地登录的用户,并授予全部权限 mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' -> WITH GRANT OPTION; # 创建一个远程登录用户,并授予全部权限 mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' -> WITH GRANT OPTION; # 最厚要刷新一下授权表 mysql> flush privileges;
原文: Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server
16、数据备份与恢复
(一)数据备份
# 1、备份一个数据库(根据提示输入密码,如果备份远程数据库,需要加上 -h 参数) $ mysqldump -h host -u username -p database_name > back_name.sql # 2、备份 test 数据库中的 emp 表(根据提示输入密码) $ mysqldump -u username -p test emp > emp.sql # 3、备份 test 数据库中的 emp 表 和 dept 表(根据提示输入密码) $ mysqldump -u username -p test emp dept > emp_dept.sql # 4、备份多个数据库 $ mysqldump -hhostname -uusername -ppassword databasename1 databasename2> multibackupfile.sql # 5、备份所有的数据库 $ mysqldump –all-databases > allbackupfile.sql # 6、只备份数据库结构 $ mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql
(二)数据恢复
# 1、还原数据库(根据提示输入密码,如果备份远程数据库,需要加上 -h 参数) $ mysql -hhostname -uusername -ppassword databasename < backupfile.sql # 2、导入数据( 常用source命令,进入某个数据库,指定备份的脚本文件) mysql> source d:\test.sql # 3、将数据库迁移至新服务器 $ mysqldump -uusername -ppassword databasename | mysql –host=*.*.*.* -C databasename
The above is the detailed content of How to add mysql to Red Hat system. For more information, please follow other related articles on the PHP Chinese website!

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.

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.

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.

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.

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.

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

When developing an e-commerce website using Thelia, I encountered a tricky problem: MySQL mode is not set properly, causing some features to not function properly. After some exploration, I found a module called TheliaMySQLModesChecker, which is able to automatically fix the MySQL pattern required by Thelia, completely solving my troubles.
