In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to add mysql to the Red Hat system. I hope you will gain a lot after reading this article. Let's discuss it together.
The method of adding mysql to the red hat system: first, log in to the red hat system as root user; then create mysql user and mysql group; then set the data storage directory; finally, enter the mysql directory, manually execute the database initialization script and modify the relevant configuration files.
Compile and install MySQL0 in the Redhat Red Hat system and log in to the system as a root user, and do the following
Some troubles can be avoided, such as not being able to set the password and not seeing the mysql library after the installation is complete.
1. Extract the general binary package to the official requirement of / usr/local, and the directory name must be mysql to enter the package directory. Execute the following command to extract the package.
Tar xf mysql****.tar.gz-C / usr/local create links
Cd / usr/local
Ln-sv mysql* mysql2, create mysql user mysql group (those who exceed 500are not system users, system users do not have home directory)
Groupadd-r-g 306 mysql
Useradd-r-g 306-u 306 mysql
Enter the mysql directory, where there is an INSTALL-BINARY file with specific installation instructions.
3. Modify the master group of all files in the mysql directory
Chown-R mysql.mysql / usr/local/mysql/*
4. Set the data storage directory to create the data directory: (specify as needed) modify the permissions of the data directory:
Chown-R mysql.mysql data directory (specifies that the data directory belongs to the master group as the mysql user mysql group)
Chmod o-rx data directory (other users do not have any permissions)
Ensure that the master group of the data directory is mysql, and other users do not have any permissions. 5. Enter the mysql directory and execute the database initialization script manually.
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. Mysql.server (mysql startup script) is copied and renamed in the mysql/support-files directory
Cp support-files/mysql.server / etc/init.d/mysqld check whether mysqld has execute permission. If not, mysqld will be added to the service list if not.
Chkconfig-- add mysqld to check whether automatic startup is enabled or not
Chkconfig-list mysqld (2345 is on) 8. Mysqld cannot be started at this time, so you need to modify the default location of the configuration file: / etc/my.cnfmysql has a unique way to read the configuration file.
Mysql configuration files are fragmented and centralized (can be configured for multiple services) [mysql]-- client configuration [mysqld]-server configuration [client]-the order in which mysql reads configuration files in effect for all client programs:
/ etc/my.cnf-- > / etc/mysql/my.cnf
-- > $BASEDIR/my.cnf (usually the installation directory)
-- > ~ / .my.cnf (the configuration file under the user's home directory, even if the mysql user does not have a home directory)
If there is a conflict between the four configuration files found, the last one shall prevail (the latter overrides the previous one
Mysql can run even without any configuration files, providing a bunch of default configuration files in the support-files directory
Copy a configuration file to / etc/my.cnf
Cp support-files/my-large.cnf / etc/my.cnf to edit and modify the configuration file
It is very important for vi / etc/my.cnf to add data directory configuration information to the [mysqld] section
Datadir = / data directory 9, start the mysqld service
Service mysqld start
View startup status
Netstat-tnlp
10. Access the mysql database
Execute mysql found command not found
Check ls / usr/local/mysql/bin/, and find mysql command
You 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 exit
Log in again and execute mysql again to access the mysql database.
11. The mysql server maintains two types of variables: defining the running characteristics of the MySQL server
View command: show global variables [like 'data%'] (used during tuning) status variable: saves the statistics of the MySQL server at runtime
View command: show global status [like 'datadir'] (for real-time monitoring) 12. Set password
[method 1] execute at the mysql prompt
Mysql > set password for 'username'@'host'=password (' password')
After modifying the user information, reread the authorization form
Mysql > flush privileges
[method 2] execute at the Linux command prompt
# mysqladmin-uUsername-hHost-p password' password' (omit-p if you don't have a password)
[method 3] modify the user table in mysql library
Update user set Password=password ("password") where user= "user" and host= "* *
Create remote access for root users of mysql (for all libraries. All tables)
Mysql > grant all privileges on. To 'root'@'192.16.%.%' identified by "password"
Reread the authorization form
Mysql > flush privileges
[method 4] the password modification method prompted after installation:
. / bin/mysqladmin-u root password' new-password'
. / bin/mysqladmin-u root-h localhost.localdomain password' new-password'
13. Add mysql help documentation to the help command
Vi / etc/man.config
Add a row
MANPATH / usr/local/mysql/man
Save exit
14. Create a database and specify the character set CREATE DATABASE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;15, create a user for SqlYog login # create a local login user, and grant full permissions mysql > CREATE USER 'monty'@'localhost' IDENTIFIED BY' some_pass';mysql > GRANT ALL PRIVILEGES ON *. * TO 'monty'@'localhost'-> WITH GRANT OPTION # create a remote login user and grant full permissions mysql > CREATE USER 'monty'@'%' IDENTIFIED BY' some_pass';mysql > GRANT ALL PRIVILEGES ON *. * TO 'monty'@'%'-> WITH GRANT OPTION;# to refresh authorization table mysql > flush privileges
Original: Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server
16. Data backup and recovery
(1) data backup
# 1. Back up a database (enter the password as prompted, if you back up the remote database Need to add-h parameter) $mysqldump-h host-u username-p database_name > back_name.sql# 2, backup emp table in test database (enter password when prompted) $mysqldump-u username-p test emp > emp.sql# 3, backup emp table and dept table in test database (enter password when prompted) $mysqldump-u username-p test emp dept > emp_dept.sql# 4, Backup multiple databases $mysqldump-hhostname-uusername-ppassword databasename1 databasename2 > multibackupfile.sql# 5, backup all databases $mysqldump-all-databases > allbackupfile.sql# 6, backup only database structure $mysqldump-no-data-databases databasename1 databasename2 databasename3 > structurebackupfile.sql
(2) data recovery
# 1. Restore the database (enter the password as prompted, and add the-h parameter if you back up the remote database) $mysql-hhostname-uusername-ppassword databasename
< backupfile.sql# 2、导入数据( 常用source命令,进入某个数据库,指定备份的脚本文件)mysql>Source d:\ test.sql# 3, migrate the database to the new server $mysqldump-uusername-ppassword databasename | mysql-host=*.*-C databasename has finished reading this article, I believe you have some understanding of the method of adding mysql in the Red Hat system, want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.