1024programmer Mysql How to add mysql to the Red Hat system

How to add mysql to the Red Hat system

The method of adding mysql in 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 You can modify the relevant configuration files.

mysql configuration file is fragmented and centralized (can be configured for multiple services)

[mysql]——client configuration
 [mysqld]——server configuration
 [client]——effective for all client programs
  • The order in which mysql reads configuration files:
    /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 Also look for the home directory)

If the four configuration files found conflict, the last one shall prevail (the latter one overrides the previous one
Even without any configuration files, mysql can run, and 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
  • It is very important to add data directory configuration information to the [mysqld] segment
    datadir = /data directory
9. Start the mysqld service

service mysqld start
Check the startup status
netstat -tnlp

10. Enter 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 script file:
vi /etc/profile.d/mysql.sh
Add export PATH=$PATH:/usr/local/mysql/bin
Save and exit
br/>Re-login, execute mysql again to enter the mysql database

11. The mysql server maintains two types of variables
  • Server variables : Define MySQL server running characteristics
    View command: show global variables [like 'data%'] (used during tuning)
  • Status variable: saved MySQL server running Time statistics
    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 & # 39; username & # 39; @ & # 39; host & # 39; = password (& #39;password');
After modifying the user information, reread the authorization table
mysql>flush privileges;

[Method 2] in Execute at the Linux command prompt
# mysqladmin -uUsername -hHost -p password 'password' (if there is no password, you can omit -p)

[Method 3] Modify the user table in the mysql database
update user set Password=password(“password”) where user=”user” and host=”***”

Create mysql root user remote access (for all databases. All tables)
mysql>grant all privileges on . to 'root'@&#39 ;192.16.%.%' identified by “password”;

Reread authorization table
mysql>flush privileges;

[Method 4] Password modification method prompted after installation:
./bin/mysqladmin -u root password 'new-password'
./bin/ mysqladmin -u root -h localhost.localdomain password & # 39; new-password & # 39;

13. Add the mysql help document to the help command

vi /etc/man.config
Add a line
MANPATH /usr/local/mysql/man
Save and exit

14. Create a database and specify 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 all 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;

 # The thickest thing is to refresh the authorization table
 mysql> flush privileges;

Original text: Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

16. Data backup and recovery

(1) Data backup

# 1. Backup one  Database (enter the password according to the prompt, if you back up the remote database, you need to add the -h parameter)
 $ mysqldump -h host -u username -p database_name > back_name.sql

 # 2. Back up the emp table in the test database (enter the password according to the prompt)
  $ mysqldump -u username -p test emp > emp.sql

 # 3. Prepare� The emp table and dept table in the test database (enter the password according to the prompt)
  $ mysqldump -u username -p test emp dept > emp_dept.sql

 # 4. Backup multiple databases
 $ mysqldump -hhostname -uusername -ppassword databasename1 databasename2> multibackupfile.sql

 # 5. Back up all databases
 $ mysqldump --all-databases > allbackupfile.sql

 # 6. Only back up the database structure
 $ mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql

(2) Data recovery

# 1. Restore the database (enter the password according to the prompt, if you back up the remote database, you need to add the -h parameter)
 $ mysql -hhostname -uusername -ppassword databasename  source d:\test.sql

 # 3. Migrate the database to the new server
 $ mysqldump -uusername -ppassword databasename | mysql –host=*.*.*.* -C databasename

The above is the detailed content of how to add mysql in the Red Hat system. For more information, please pay attention to 1024programmer.com Others related articles!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/how-to-add-mysql-to-the-red-hat-system/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索