MySQL database installation and configuration under Linux

Source: Internet
Author: User

1. Install MySQL database first download mysql from the MySQL website, then go to the directory where you downloaded the installation files, run the following command to install, Where mysql-server-community-5.1.56-1.rhel5.i386.rpm is the RPM package for the MySQL database server that you just downloaded, and then uses/etc/rc.d/init.d/ Mysqlrestart command to restart the MySQL service:
    1. [Email protected] ~]# RPM-IVH mysql-server-community-5.1.56-1.rhel5.i386.rpm
    2. [Email protected] ~]#/etc/rc.d/init.d/mysql restart
    3. Shutting down MySQL. Determine
    4. Starting MySQL. Determine

2. Configuring the MySQL database character set

Note: The purpose of configuring the MySQL database character set is to facilitate the use of the database, do not need to temporarily set the database character sets each time the connection, the individual does not recommend this method, the real project should be connected to the database temporarily set the database character sets, so as to facilitate the system migration, And it doesn't affect the use of other databases in the database server!

After the installation is complete, you need to configure the MySQL character set configuration, first need to find the location of the MySQL configuration file, because the MySQL configuration file name is the. CNF end, so you can use the following command to find:

    1. [[email protected] ~]# Find/-iname ' *.cnf '-print
    2. /usr/share/mysql/my-large.cnf
    3. /usr/share/mysql/my-medium.cnf
    4. /usr/share/mysql/my-innodb-heavy-4g.cnf
    5. /usr/share/mysql/my-huge.cnf
    6. /usr/share/mysql/my-small.cnf
    7. /usr/share/doc/mysql-server-community-5.1.56/my-large.cnf
    8. /usr/share/doc/mysql-server-community-5.1.56/my-medium.cnf
    9. /usr/share/doc/mysql-server-community-5.1.56/my-innodb-heavy-4g.cnf
    10. /usr/share/doc/mysql-server-community-5.1.56/my-huge.cnf
    11. /usr/share/doc/mysql-server-community-5.1.56/my-small.cnf
    12. /etc/pki/tls/openssl.cnf

After entering the command "Find/-iname ' *.cnf '-print" Enter, the screen displays the MySQL configuration file that you searched for and then copies My-large.cnf, MY-MEDIUM.CNF, MY-INNODB-HEAVY-4G.CNF, MY-HUGE.CNF, my-small.cnf any one to the/etc directory, and named My.cnf, whose commands are as follows:

    1. [Email protected] ~]# CP/USR/SHARE/MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF
    2. [Email protected] ~]# VI/ETC/MY.CNF

Then, using the VI editor, modify the/etc/my.cnf file and add it under [client]: "default-character-set=gb2312"; under [Mysqld], add: "default-character-set= gb2312 ". As shown below:

  1. # The following options would be passed to all MySQL clients
  2. [Client]
  3. default-character-set=gb2312
  4. #Password = your_password
  5. Port = 3306
  6. Socket =/var/lib/mysql/mysql.sock
  7. # here follows entries for some specific programs
  8. # The MySQL server
  9. [Mysqld]
  10. default-character-set=gb2312
  11. Port = 3306
  12. Socket =/var/lib/mysql/mysql.sock
  13. Skip-locking
  14. Key_buffer_size = 16M
  15. Max_allowed_packet = 1M
  16. Table_open_cache =
  17. Sort_buffer_size = 512K
  18. Net_buffer_length = 8K

Click the ESC key, enter ": Wq" after the return to save the configuration file, enter "/etc/rc.d/init.d/mysqlrestart" Restart the MySQL service, as follows:

    1. [Email protected] ~]#/etc/rc.d/init.d/mysql restart
    2. Shutting down MySQL. Determine
    3. Starting MySQL. Determine

Finally, we verify that the MySQL server configuration is successful, first log in to MySQL, enter the "mysql–uroot-p" carriage return, the system prompts for a password, log in successfully after entering the MySQL command mode, as follows:

  1. [Email protected] ~]# mysql-uroot-p
  2. Enter Password:
  3. Welcome to the MySQL Monitor. Commands End With; or \g.
  4. Your MySQL Connection ID is 2
  5. Server Version:5.1.56-community-log MySQL Community Server (GPL)
  6. Copyright (c), Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of the Oracle Corporation and/or its
  8. Affiliates. Other names trademarks of their respective
  9. Owners.
  10. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
  11. MySQL>

In MySQL command mode, enter "show variables like ' collation_% ';", "show variables like ' character_set_% ';" The character set is displayed after the carriage return as follows:

  1. MySQL> Show variables like ' collation_% ';
  2. +----------------------+-------------------+
  3. | variable_name | Value |
  4. +----------------------+-------------------+
  5. | collation_connection | Gb2312_chinese_ci |
  6. | Collation_database | Gb2312_chinese_ci |
  7. | Collation_server | Gb2312_chinese_ci |
  8. +----------------------+-------------------+
  9. 3 rows in Set (0.05 sec)
  10. MySQL> Show variables like ' character_set_% ';
  11. +--------------------------+----------------------------+
  12. | variable_name | Value |
  13. +--------------------------+----------------------------+
  14. | character_set_client | gb2312 |
  15. | character_set_connection | gb2312 |
  16. | Character_set_database | gb2312 |
  17. | Character_set_filesystem | binary |
  18. | Character_set_results | gb2312 |
  19. | Character_set_server | gb2312 |
  20. | Character_set_system | UTF8 |
  21. | Character_sets_dir | /usr/share/mysql/charsets/|
  22. +--------------------------+----------------------------+
  23. 8 rows in Set (0.00 sec)
  24. MySQL>

According to the above query results, we set the MySQL database configuration information has been effective, to complete the installation and configuration of MySQL server.

3. Some considerations for MySQL Database 3.1 remote connection MySQL Slow resolution: Add a configuration like this in the MySQL server configuration (/etc/my.cnf) to quickly.
    1. [Mysqld]
    2. Skip-name-resolve
Note: This enables DNS resolution to be disabled, and the connection speed is much faster. However, it is not possible to use the hostname in the MySQL authorization table and only use the IP format.
3.2 After restarting the database, it is found that no password (or any password) can be used to connect the workaround: Check your MySQL configuration file (/etc/my.cnf) for a more statement: "Skip-grant-tables", delete (comment) the statement, Reconfigure the MySQL password and restart the MySQL service again! Note: If you use the Skip-grant-tables system will not do any user access control, but you can use mysqladmin flush-privileges or mysqladmin reload to turn on access control; By default, show The databases statement is open to all users, and if the MySQL server does not have a remote account open, add Skip-grant-tables to the/ETC/MY.CNF.

Blog Address : http://blog.csdn.net/shuxiao9058

Original author : Kevdzija

MySQL database installation and configuration under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.